LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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.

Notices


Reply
  Search this Thread
Old 09-27-2005, 06:50 AM   #1
mayyash
LQ Newbie
 
Registered: Jul 2004
Location: Helsinki, Finland
Distribution: Fedora Core 3
Posts: 19

Rep: Reputation: 0
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?
 
Old 09-30-2005, 02:23 AM   #2
LinuxLala
Senior Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: Fedora 7
Posts: 1,305

Rep: Reputation: 45
Maybe you can share your script and some elegant solution can be derived from it
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ordering row entries rohr Programming 4 04-11-2005 03:36 AM
How to write the contents of a column as a row in linux markraem Linux - Software 4 07-17-2004 07:35 PM
MySQL Row Limit agallant Programming 1 06-25-2004 11:16 AM
MPlayer - Green Row Micro420 Linux - Software 4 10-13-2003 10:14 AM
Mplayer - Blue row R-mus Linux - Software 1 09-07-2003 01:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration