Dispay Sorted Lines of a File
$ cat apple.txt core worm seed jewel $ sort apple.txt core jewel worm seed $ cat net.txt CRAB BARNACLE BARNACLE CRAB SALMON BARNACLE BARNACLE BARNACLE BARNACLE $ sort net.txt BARNACLE BARNACLE BARNACLE BARNACLE BARNACLE BARNACLE CRAB CRAB SALMON $ sort -u net.txt BARNACLE CRAB SALMON $
You can use other options of sort to get a file in alphabetical order; for example, you can use the b, and f options of sort to: ignore leading blanks (b), and fold upper case and lower case letters together (f).
$ cat poem.txt
snow
ice
tiny lights
the
winter
Reaches
to
a
glowing, cold
Moon
$ sort poem.txt
tiny lights
to
winter
Moon
glowing, cold
a
ice
the
snow
Reaches
$ sort -b poem.txt
Moon
Reaches
a
glowing, cold
ice
snow
the
tiny lights
to
winter
$ sort -bf poem.txt
a
glowing, cold
ice
Moon
Reaches
snow
the
tiny lights
to
winter
$
