[desktop ~]$ cat sa
sanmesh
shammas
sujil
givin
nepo
bijal
[desktop ~]$ sed -i -e '1i Header' -e '$a Trailor' sa
[desktop ~]$ cat sa
Header
sanmesh
shammas
sujil
givin
nepo
bijal
Trailor
-
4have you tried searching in sed manual? Voting to close – RomanPerekhrest Dec 8 '17 at 11:48
sed -i -e '1i Header' -e '$a Trailor' sa
-i
:
Edits the file in place
-e script
:
Add the script to the commands to be executed
'1i Header'
:
Match 1st line ('1') and insert ('i') 'Header'
'$a Trailor'
:
Match last line ('$') and append ('a') 'Trailor'
-
-
1
-