← cd ~/posts
Mar 19, 2014 #shell #pipes

Linux Redirection and Pipes

# output redirection

cat 123.txt > onetwothree.txt redirects output to a file — default nature is to clobber the target file and populate it from the input stream

# append redirection

cat 123.txt >> number.txt creates number.txt if it does not exist, or appends if it does
cat 456.txt >> number.txt appends more content to the same file

# pipes

Pipes connect the output stream of one command to the input stream of a subsequent command.

cat 123.txt | sort sort the contents of a file
cat 456.txt 123.txt | sort concatenate two files, then sort
cat 456.txt 123.txt | sort | grep 3 chain multiple pipes: concatenate, sort, then filter
← back to all posts