How to insert or add new line in a file using shell (sh) script in linux
To add a new line in to an existing file can be done easily in linux using a command sed
sed '45i\newline here' filename
The above command will insert "newline here" on the 45th line in the contents of the filename and print the result as output.
We can redirect the output to a temp file and then mv it back as old file
sed '45i\newline here' filename > tempfilename
mv -f tempfile filename