How to insert data to the first line of a file in bash
To insert data to the first line of a file in bash, we can use sed utility.
#sed -i '1i data' file
where,
data - data to be inserted
file - name of the file to be processed
The same can be do using the echo command.
#echo 'data'$'\n'"$(cat file)" > file
where,
data - data to be inserted
file - name of the file to be processed