Here's another pipeline example:
$ cat myfile.txt | sort | uniq | wc -l
We use cat to feed the contents of myfile.txt
to the sort
command. When the sort command receives the input, it sorts all input lines so
that they are in alphabetical order, and then sends the output to
uniq
. uniq
removes any duplicate lines, sending the
scrubbed output to wc -l
. We've seen the wc
command
earlier, but without command-line options. When given the -l
option, it prints only the number of lines in its input, instead of also
including words and characters. Try creating a couple of test files with your
favorite text editor, and use this pipeline to see what results you get.