December 1999
Beginner
528 pages
11h 10m
English
Sort can be used to sort the usernames from the /etc/passwd file. All we need to do is sort on field 1, which is the login name field, then pass the output using a pipe to awk, and let awk print the first field.
$ cat passwd | sort -t: +0 | awk -F":" '{print $1}'
adm
bin
daemon
...
...
Sort can also be used on the df command to print the usage column in desending order. Here’s a normal df output.
$df
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/hda5 495714 291027 179086 62% /
/dev/hda1 614672 558896 55776 91% /dos
Now using -b option, which ignores any leading blanks when sorting, we use field 4 (+4), which is the ‘capacity’ column. Reversing the sort gives a clearer picture of the free space on ...
Read now
Unlock full access