Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am trying to connect multiple lines comming form a command into a single line, the net effect i am trying to acheive is to transpose a column into a row.
Here is the input text, coming from Top:
CPU TTY PID USERNAME %WCPU %CPU COMMAND
3 ? 20339 user1 6.41 6.40 myprocess1
2 ? 20343 user1 2.41 2.41 myprocess2
2 ? 20332 user1 1.82 1.82 myprocess3
2 ? 20337 user1 0.69 0.69 myprocess4
(edited to save you the clutter)
So what I want t achieve is to get the %CPU usage per process. The script I am writing will execute periodically and the end output should be something like
Time myprocess1 myprocess2 myprocess3
t1 % % %
t2 % % %
i.e. each run of the script will add a new row to the log file.
(and if you must know, it will then be plot using excel)
There can be many clumsy solutions, but I am looking for the shortest, least CPU-using one. I also have perl option, but I am not much of a perl scripter.
I am also open to other methods all together to acheive the same result.