ps with --sort option


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ps with --sort option
# 1  
Old 05-10-2007
Question ps with --sort option

Good morning,

Using command
Code:
root@slackware:~# ps -e -O sz --sort sz

part of the output is:
Code:
  PID    SZ S TTY          TIME COMMAND
 ...
   57   358 S ?        00:00:00 /usr/sbin/syslogd
   60   347 S ?        00:00:00 /usr/sbin/klogd -c 3 -x
  103   347 S ?        00:00:00 udevd
  119   353 S ?        00:00:01 /sbin/dhcpcd -d -t 60 eth0
  869     0 S ?        00:00:00 [khubd]
  894   354 S ?        00:00:00 /usr/sbin/inetd
  898   820 S ?        00:00:00 /usr/sbin/sshd
  909   395 S ?        00:00:00 /usr/sbin/crond -l10
  911   396 S ?        00:00:00 /usr/sbin/atd -b 15 -l 1
  914  1362 S ?        00:00:05 sendmail: accepting connections
  917  1270 S ?        00:00:00 sendmail: Queue runner@00:25:00 for /var/spool/c
...

No matter what is the --sort option, the output is sorted by PID.
How can I sort the list by the SZ column ?

Thank you in advance
# 2  
Old 05-10-2007
Jonas,
See if this would work for you:
Code:
ps -e -o "osz pid s tty time comm" | head -1
ps -e -o "osz pid s tty time comm" | tail +2 | sort -n

# 3  
Old 05-11-2007
Yes it works.

Thank you
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

2. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

3. Shell Programming and Scripting

Help with sort word and general numeric sort at the same time

Input file: 100%ABC2 3.44E-12 USA A2M%H02579 0E0 UK 100%ABC2 5.34E-8 UK 100%ABC2 3.25E-12 USA A2M%H02579 5E-45 UK Output file: 100%ABC2 3.44E-12 USA 100%ABC2 3.25E-12 USA 100%ABC2 5.34E-8 UK A2M%H02579 0E0 UK A2M%H02579 5E-45 UK Code try: sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Discussion started by: perl_beginner
2 Replies

4. Shell Programming and Scripting

Alternate to sort --random-sort

sort --random-sort The full command is path=`find /testdir -maxdepth 1 -mindepth 1 -type d | ***Some sort of sort function*** | head -1` I have a list I want to randomly sort. It works fine in ubuntu but on a 'osx lion' sort dosen't have the --random-sort option. I don't want to... (5 Replies)
Discussion started by: digitalviking
5 Replies

5. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

6. Shell Programming and Scripting

sort -t option causing code to fail need ASCII character

Hello, When I run this UNIX code without the -t option it gives me the desired results. The code keeps the record with the greatest datetime based on the key columns. I sort it first then sort it again with the -u option, that's it. I need to have a variable to specify an ASCII character... (2 Replies)
Discussion started by: script_op2a
2 Replies

7. UNIX for Dummies Questions & Answers

Help with Sort option

Hello, I'm sure this is an easy one but I've tried loads of sort options and none of them work. I'm trying to sort a file by alpha-numerical order but it's not working. My file is: SN023x SN047x SN085x SN124x SN178x SN480x SN1004x After I sort it the highest number server (1004) is in... (4 Replies)
Discussion started by: Grueben
4 Replies

8. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

9. Shell Programming and Scripting

How to Sort Floating Numbers Using the Sort Command?

Hi to all. I'm trying to sort this with the Unix command sort. user1:12345678:3.5:2.5:8:1:2:3 user2:12345679:4.5:3.5:8:1:3:2 user3:12345687:5.5:2.5:6:1:3:2 user4:12345670:5.5:2.5:5:3:2:1 user5:12345671:2.5:5.5:7:2:3:1 I need to get this: user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
Discussion started by: daniel.gbaena
7 Replies

10. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies
Login or Register to Ask a Question