Sort is often used to organize the output in asc/desc order.
Here are prominent options used with sort.
-n:sort in numeric order
-r:sort in reverse order
-t:Used to specify delimiter
-k:used to specify field number.
Lets explore the option with example.
Sort all users according to their names.
#sort -t ":" -k 1 /etc/passwd
Sort all users according to uid.
#sort -t ":" -k 3 -n /etc/passwd
Reverse sort above two queries .
#sort -t ":" -k 1 -r /etc/passwd
#sort -t ":" -k 3 -n -r /etc/passwd
Search This Blog
Showing posts with label sort. Show all posts
Showing posts with label sort. Show all posts
Monday, January 23, 2012
Wednesday, June 1, 2011
How to find Big Size File and Folder in Linux?
Here is the trick
Use the following to find the spacious directory.
#find / -type d -exec ls -ld {} \; |sort -nrk5|head
Use the following to find the spacious file.
#find / -type f -exec ls -ld {} \; |sort -nrk5|head
The output may take time depending on your system performance.
Use the following to find the spacious directory.
#find / -type d -exec ls -ld {} \; |sort -nrk5|head
Use the following to find the spacious file.
#find / -type f -exec ls -ld {} \; |sort -nrk5|head
The output may take time depending on your system performance.
Subscribe to:
Posts (Atom)