home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / shell / 3182 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  1.8 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!hermes.chpc.utexas.edu!news.utdallas.edu!convex!tchrist
  2. From: tchrist@convex.COM (Tom Christiansen)
  3. Newsgroups: comp.unix.shell
  4. Subject: Re: Sort problem . .
  5. Message-ID: <1992Jul29.162453.17880@news.eng.convex.com>
  6. Date: 29 Jul 92 16:24:53 GMT
  7. References: <1992Jul29.072924*Harald.Eikrem@delab.sintef.no> <1992Jul29.160600.9623@leland.Stanford.EDU>
  8. Sender: usenet@news.eng.convex.com (news access account)
  9. Reply-To: tchrist@convex.COM (Tom Christiansen)
  10. Organization: CONVEX Realtime Development, Colorado Springs, CO
  11. Lines: 31
  12. Originator: tchrist@pixel.convex.com
  13. Nntp-Posting-Host: pixel.convex.com
  14. X-Disclaimer: This message was written by a user at CONVEX Computer
  15.               Corp. The opinions expressed are those of the user and
  16.               not necessarily those of CONVEX.
  17.  
  18. From the keyboard of peer@ccrma.stanford.edu (Peer Landa):
  19. :It seems like this is getting out of hand, or drifting away from my original  
  20. :posting . . where I asked to get a command line (or script) to list & sort all  
  21. :my processes by memory use without getting the "title line" on the bottom --  
  22. :i.e the "title line" shall stay at the top (that's why 'ps uax | sort -nr +3'  
  23. :doesn't work). One way to do this (thanks to Erick Rudiak) is: 
  24.  
  25. :TITLELINE=`ps aux | head -1`
  26.  
  27. Just use
  28.  
  29.     ps u$$ | sed 1q
  30.  
  31. :echo "$TITLELINE"
  32.  
  33. And now you can delete that.
  34.  
  35. :ps -aux | grep -v PID | sort -rn +3
  36.  
  37. No need to grep every line:
  38.  
  39.     ps aux | sed 1d | sort -rn +3
  40.  
  41. although the perl solution runs faster, to my admitted surprise.
  42.  
  43. --tom
  44. -- 
  45.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  46.     If you have ever seen the grim word "login:" on a screen, your mind
  47.     is now a wholly-owned subsidiary of The Death Star.
  48.                 John Woods in <14105@ksr.com> of comp.unix.bsd
  49.