6REDIRECTION

image

In this lesson we are going to unleash what may be the coolest feature of the command line. It’s called I/O redirection. The “I/O” stands for input/output, and with this facility you can redirect the input and output of commands

to and from files, as well as connect multiple commands together into powerful command pipelines. To show off this facility, we will introduce the following commands:

cat Concatenate files

sort Sort lines of text

uniq Report or omit repeated lines

grep Print lines matching a pattern

wc Print newline, word, and byte counts for each file

head Output the first part of a file

tail Output the last part of a file ...

Get The Linux Command Line, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.