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 > operatoralways overwrites existing output files
Syntax to save the output of a command to a file
Example
Saving the date command output to a file called 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
Example
Saving and appending the date command output to a file called output.txt
>
>>
The > operator
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