Tutorial by Examples

sort command is used to sort a list of lines. Input from a file sort file.txt Input from a command You can sort any output command. In the example a list of file following a pattern. find * -name pattern | sort
If each lines of the output need to be unique, add -u option. To display owner of files in folder ls -l | awk '{print $3}' | sort -u
Suppose we have this file: test>>cat file 10.Gryffindor 4.Hogwarts 2.Harry 3.Dumbledore 1.The sorting hat To sort this file numerically, use sort with -n option: test>>sort -n file This should sort the file as below: 1.The sorting hat 2.Harry 3.Dumbledore 4.Hogwa...
Suppose we have this file: test>>cat Hogwarts Harry Malfoy Rowena Helga Gryffindor Slytherin Ravenclaw Hufflepuff Hermione Goyle Lockhart Tonks Ron Snape Olivander Newt Ron Goyle Flitwick ...

Page 1 of 1