LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   writing output to file (https://www.linuxquestions.org/questions/linux-general-1/writing-output-to-file-376516/)

Hockeyfan 10-24-2005 05:49 PM

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.

Hockeyfan

dracolich 10-24-2005 05:59 PM

Try it without the numbers, like this:

ls -l > filename

Hockeyfan 10-24-2005 06:03 PM

Thanks I should have realized that. I think I use the numbers when there are errors in the output.

cs-cam 10-24-2005 08:02 PM

There are two streams, stdout and stderr. stdout is standard output and stderr is where error messages go.
Code:

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



All times are GMT -5. The time now is 12:11 AM.