Sorting commands

The command to sort the contents of the file is

#ls -al | sort

and to reverse the sorting order we use r at the end of the command as shown below

#ls -al | sort r

The command to sort the contents of the directory in disk usage basis is as follows

# du -s * | sort -n

and similarly to reverse the sorting order we use r at the end of the command as shown below

# du -s * | sort -nr

Reference: http://www.softpanorama.org/Tools/sort.shtml

Leave a Reply

Protected by WP Anti Spam