Redirect output to a file in linux
July 8, 2009
Its’ been kind of a while since I blogged on Linux.Sometimes we might require the outputs generated by a command to be stored in a text file for future use..This entry is all about dealing that.
There are essentially two different ways of doing it,depending on your requirement
1. commandname > filename
sample: ls > output.txt
The file is created in the current working directory.Upon usage of ‘>’,the previous contents are erased,and the new contents are written.
2. Sometimes you’ll need the contents to be preserved,In such a case use ‘>>’
eg: ls >> anerudh.txt
In this case,the file is updated,and your previous contents are unaltered.
Cheerio
Entry Filed under: 1. Tags: files, linux, output in file, redirect output, shell, shell scripting, terminal.
Trackback this post | Subscribe to the comments via RSS Feed