EN
Bash - append output at the end of text file
0 points
In this article, we would like to show you how to append output at the end of text file in Bash.
Quick solution:
xxxxxxxxxx
1
command_name >> file_name.txt
Where:
command_name
- is name of the command that returns some output,file_name
- is name of the text file where we want to append the command output.
In this example, we use echo
command that displays a line of text that is passed in as an argument. Using >>
operator we "redirect" its output and append it at the end of file.txt
.
xxxxxxxxxx
1
echo "Some text..." >> file.txt
Note:
This operation will write at the end of
file.txt
leaving the previous content. If you want to overwrite the whole file content, use>
instead of>>
operator.