You can save the output to file using shell redirection. To redirect command output to a file, enter:
command > filename
[donotprint][/donotprint]You need to replace command with the command you want to rune and filename with the file to which you want to direct the output for example:
date > output.txt
ls -l /etc/ > filelist.txt
To display saved output use cat command or more command as follows
How do I save (append) output to an existing output file?
echo "Today's date is" >> foo.txt date >> foo.txt cat foo.txt
Today's date is Tue Feb 4 23:26:06 IST 2014
How do I save output of one file to another?
# use cp to duplicate file1 to file2 cp file1 file2 cat file1 cat file2 # use cat command to save output of file3 to file4 cat file3 > file4 cat file4
Redirect error and output messages to an output file
The following special command redirect both standard error and standard output data to an output file called file.txt
command > file 2>&1 find /etc/ -name "*.conf" > file.txt 2>&1 cat file.txt