Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add new colum as date field

Status
Not open for further replies.

mativare

Programmer
Feb 13, 2007
2
EE
he I have simple script.
ps -efo 'stime user pid pcpu rss pmem comm'
How to add first colum as date from date command and have column header date.
Thanks
Matt
 
Hi mativare,

Your command is invalid. I get the following message:

#ps -efo 'stime user pid pcpu rss pmem comm'
ps: 0509-048 Flag -o was used with invalid list.
 
ps -efo etc works on Solaris, but haven't yet figured a way to add the date to the output.

 
Hi

dstxaix said:
Your command is invalid.
Please note that there are differences between [tt]ps[/tt] implementations for different operating systems. Just because your [tt]ps[/tt] does not understands it, does not mean that is invalid. My [tt]ps[/tt] on Linux executes it correctly.

Matt, please specify on what system you run that command.

I do not really understand what you need, but I hope this is close to that.
Code:
ps -efo 'stime user pid pcpu rss pmem comm' | while read d l; do test "$d" == "STIME" && echo "Date $l" || echo "`date -d $d` $l"; done
Tested with GNU [tt]date[/tt].

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top