Sai Karthik
Balancing the braces ...How to append / prepend text to files in Bash
There are multiple ways to append/prepend text to files. I am demonstrating the methods which i regularly use.
First, Let’s check the contents of the file fruits.txt
|
|
Appending Text:
We could use the symbol >>
to append text to a file
|
|
Now, Let’s check the contents again
|
|
You can observe that the grapes
is added to the last line of the file.
Prepending Text:
This will add text to the beginning of the file
|
|
Let’s see the output of the file
|
|
You can observe that the grapes
is added to the first line of the file.
Tags: bash