Redirecting The Outp Put to a text file?
Hi All
How can I redirect Output of any Linux Command to the file?..
Thanx
pady
Linux
Hi All
How can I redirect Output of any Linux Command to the file?..
Thanx
pady
by michael2
command > file.txt
command >> file.txt
A single gt sign will create a new file with the name of the file you specify. If that file exists it will be overwrittin. If you use double gt signs the output of the command will be appended to the file of that name. If the file name doesn;t exist it will be created.
by parth_d
by achuprinin
It depends on what do you want:
- if you want redirect ONLY standart output use redirection sign '>' (greater) to create new file for output or put it twice to add to the end of existing file. Ex.:
command > newfile
command >> existingfile
- if you want redirect both standart output and error output add '2>&1' at the end of command line. Ex.:
command args > newfile 2>&1
command args >> existingfile 2>&1
- if you want redirect full output to file but also to see what command sends to output use `tee' filter. Ex.:
command args 2>&1 |tee newfile
command args | tee -a existingfile
by parth_d
by parth_d
This discussion is closed to new replies.
Sort by Trending