General discussion

Locked

Redirecting The Outp Put to a text file?

By parth_d ·
Hi All

How can I redirect Output of any Linux Command to the file?..

Thanx
pady

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Redirecting The Outp Put to a text file?

by dhuynh In reply to Redirecting The Outp Put ...

% my_command >> mytexfile.txt

Collapse -

Redirecting The Outp Put to a text file?

by parth_d In reply to Redirecting The Outp Put ...

Poster rated this answer

Collapse -

Redirecting The Outp Put to a text file?

by Michael2 In reply to Redirecting The Outp Put ...

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.

Collapse -

Redirecting The Outp Put to a text file?

by parth_d In reply to Redirecting The Outp Put ...

Poster rated this answer

Collapse -

Redirecting The Outp Put to a text file?

by achuprinin In reply to Redirecting The Outp Put ...

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

Collapse -

Redirecting The Outp Put to a text file?

by parth_d In reply to Redirecting The Outp Put ...

Poster rated this answer

Collapse -

Redirecting The Outp Put to a text file?

by parth_d In reply to Redirecting The Outp Put ...

This question was closed by the author

Back to Linux Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums