Transposing a column into a row
Hi,
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 % % % etc 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. Any ideas? |
Maybe you can share your script and some elegant solution can be derived from it :)
|
All times are GMT -5. The time now is 05:45 AM. |