[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] Using awk
>
> How about this?
>
> root [at] server# df | awk /%/ | sort +5
> /dev/ar0s1a 1012974 53260 878678 6% /
> devfs 1 1 0 100% /dev
> /dev/ar0s1d 1012974 9490 922448 1% /tmp
> /dev/ar0s1f 65327520 15440068 44661252 26% /usr
> /dev/ar0s1e 8122126 62762 7409594 1% /var
>
This does the sort, but shifts the header line to the end:
df -k | sort -k6
so to get round that, use awk to skip the header line:
$ df -k | awk 'BEGIN { getline; print $0 } { print $0 | "sort -k6" }'
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/sda12 2016016 172924 1740680 9% /
/dev/sda5 23302 6439 15660 29% /boot
/dev/sda7 4032092 993372 2833896 26% /home
/dev/sda9 497829 14 472113 0% /tmp
/dev/sda8 4032092 2835352 991916 74% /usr
/dev/sda6 161077484 137040948 15854232 90% /usr2
/dev/sda11 497829 52732 419395 11% /var
Chris...
--
\ Chris Johnson \
\ cej [at] nightwolf.org.uk ~-----,
\ http://cej.nightwolf.org.uk/ ~-----------------------------------,
\ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____
___________________________________________________________________
Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html
GNU the choice of a complete generation.