Monday, August 18, 2008

Redirection

To redirect the output to a file use '>' command
example :
ls -l > example.txt
'>' command replace the existing content of the file. If you want to append the output to with existing content, use '>>'
example:
ls -l >> example.txt
'<' command use to get the input from a file.
example:
cat < example.txt
This redirection command doesn't know where is the input come from.
For example if you use
wc -w < example.txt
It only outputs the number of words in the file.

If you use wc -w example.txt instead of that you will get the number of words and the name of the file.

No comments: