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: , , , , , , .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Tweets

Visitor Count

Archives

Tag Cloud

.deb .deb.deb anatomy .tar .tar.gz ac milan argentina berbatov bunny carlitos compress configure control control.tar.gz data.tar.gz debian fans Football gravity lean Humour install linux make Manchester United Manutd md5sums Michael Jackson MJ dead MJ dies Old trafford opensuse package packages perez POP KING postinst postrm prerm Race Racism Racist Real Madrid Ronaldo Russel Peters SAF tevez

Blogroll

Categories

SocialVibe