Command Redirection

Linux shells allow the input and output of a command to be redirected, using the symbols < and >. For example, you can use the contents of a text file as input into the mysql database command:

mysql db < db_commands.txt

You can redirect the output of the cat command into another file:

cat some_text_file.txt > another_text_file.txt

You can also use a "pipe", represented by the | symbol, to string two command together. A pipe takes the output of one command and uses it as the input of another command. For example, you can use grep to look for a string in a file, sort the output and use more to display the output page by page:

grep some_string some_file.txt | sort | more