Skip to main content
IBM 
ShopSupportDownloads
IBM HomeProductsConsultingIndustriesNewsAbout IBM
IBM : developerWorks : Linux : Education - Tutorials
LPI certification 101 exam prep, Part 2
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
5. Text processing
  


A longer pipeline page 4 of 14


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.


Main menuSection menuFeedbackPreviousNext
PrivacyLegalContact