How to save the output of a Linux/Unix command to a file

Share:
The Bash / KSH and POSIX shell provides a file redirection option to redirect the output of commands to a file using the following two operators

> is output redirection symbol
>> is append output redirection symbol


The > operator always overwrites existing output files

Syntax to save the output of a command to a file

 command > filename  

Example

Saving the date command output to a file called output.txt

 $ date > output.txt  

In this example, save the output of the date command to a file called output.txt

The >> operator appends the output of a command with the same file as

Syntax to save and append the output of a command to a file

 command >> filename  

Example

Saving and appending the date command output to a file called output.txt

 $ date >> output.txt  

No comments

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();

Ads