du -sh *| sort -rn in solaris 10

Hi all

     The command over does not sort corrrectly when used with du -sh \(Solaris 10\).  I have to use du -sk *|sort -rn to sort in the right order.  Have anybody has this problem.

The -sh option is:
All sizes are scaled to a human readable format, for example, 14K, 234M, 2.7G, or 3.0T. Scaling is done by repetitively dividing by 1024.

Thus, you would have to create an awk script or other function to sort to:
T G M K -- since there is no sort to put them in order.

Or, use the -sk option, then awk (or other function) to convert to human-readable.

'cause '-h' stands for:

     -h    All sizes are scaled to a human readable  format,  for
           example,  14K, 234M, 2.7G, or 3.0T. Scaling is done by
           repetitively dividing by 1024.

Ciao,
ho scritto una sequenza di comandi per questa necessit� , ti faccio un esempio:

[root@server]#pwd
/var

[root@server]# \du -sh * | tee /tmp/prova.txt | grep G | sort -rn ; cat /tmp/prova.txt | grep M | sort -rn ; cat /tmp/prova.txt | grep K | sort -rn ; rm /tmp/prova.txt

1.2G spool
1.1G sadm
239M apache2
139M opt
45M smop
38M tmp
[...]
983K cron
937K lib
552K lp
162K cache
153K ldap
131K snmp
128K run
74K preserve
[...]

L'ho testato pi� volte e funziona alla grande!

Hello.

Per our forum rules, all posts must be in English.

We do provide translation services for posts from English to a number of languages as a benefit to users. However, posts must be in English.

Please repost in English.

Thank you for your cooperation.

The UNIX and Linux Forums.

Hi,
i wrote a commands sequence for this purpose , this is an example:

[root@server]#pwd
/var

[root@server]# \du -sh * | tee /tmp/prova.txt | grep G | sort -rn ; cat /tmp/prova.txt | grep M | sort -rn ; cat /tmp/prova.txt | grep K | sort -rn ; rm /tmp/prova.txt

1.2G spool
1.1G sadm
239M apache2
139M opt
45M smop
38M tmp
[...]
983K cron
937K lib
552K lp
162K cache
153K ldap
131K snmp
128K run
74K preserve
[...]

I used it many times and it works GREAT!