troubleshooting Question

Need help with writing a Shell script (using awk/sort/sed) to sort "ps -ef" output

Avatar of sunhux
sunhux asked on
Unix OSLinux
23 Comments1 Solution1029 ViewsLast Modified:
Tintin, JustUnix or anyone else,

I would like some help with writing a Shell script to do some sorting/reformatting
of "ps -ef" output for HP-UX & Solaris & Redhat platform :

Eg: example "ps -ef" output :
     UID   PID  PPID  C    STIME TTY      TIME CMD
    root     0     0     0   Apr 21  ?          0:01 sched
    sde 21302  1    0 06:16:04 ?           0:00 /appl/cgs/sdeexe92
    sde 21313  1    0 06:16:12 ?           0:01 /appl/cgs/sdeexe92


Would like the output to be sorted by CMD column in descending
order (as primary key) & then sorted by TIME column in descending
order (as secondary key).

So the output would become :
     /appl/cgs/sdeexe92   0:00  sde 21302   1    0   06:16:04 ?
     /appl/cgs/sdeexe92   0:01  sde 21313   1    0   06:16:12 ?  
     sched                         0:01 root     0       0     0   Apr 21  ?        

Thanks
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 23 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros