Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 10-24-2005, 06:49 PM   #1
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Rep: Reputation: 30
writing output to file

What is the command to write the output of the comand to a file?

I think it goes something like this:

ls -l 2&>1 outputfile

Am I right? I tried that and I got an file wriiten but it didn't work.

Old 10-24-2005, 06:59 PM   #2
Senior Member
Registered: Jul 2005
Distribution: Slackware
Posts: 1,173

Rep: Reputation: 47
Try it without the numbers, like this:

ls -l > filename
Old 10-24-2005, 07:03 PM   #3
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Original Poster
Rep: Reputation: 30
Thanks I should have realized that. I think I use the numbers when there are errors in the output.
Old 10-24-2005, 09:02 PM   #4
Senior Member
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 56
There are two streams, stdout and stderr. stdout is standard output and stderr is where error messages go.
ls -l > file.txt  # will dump only stdout to file.txt
ls -l 2> file.txt  # will dump only stderr to file.txt
ls -l &> file.txt  # will dump both streams to file.txt


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
dd: writing to `/dev/hdc': Input/output error derekpc Linux - General 1 12-01-2005 12:46 PM
why when redirecting output to a file any file extension seems to be fine? dr_zayus69 Linux - General 1 05-21-2005 05:09 AM
writing to file ej25 Programming 17 11-19-2004 12:23 PM
writing a strcutures to a file xemous Programming 2 09-03-2004 03:57 AM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 08:17 PM

All times are GMT -5. The time now is 05:34 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration