Issue
I have a file where i need to put 7 spaces for the first line and 3 spaces for all the other lines.
So i did this (i put 1d to ignore the first line) :
sed -i '1 s/^/ /' $f
sed -i '1d s/^/ /' $f
It works for the first line spaces but the other one gives me this error :
sed: -e expression #1, char 4: extra characters after command
Solution
sed '
# more spaces for the first line
1s/^/ /
# less spaces for all the other lines.
1!s/^/ /
'
You can learn sed at https://www.grymoire.com/Unix/Sed.html#uh-25 https://www.gnu.org/software/sed/manual/sed.html .
You could also do like subtraction, add 4 spaces on first line and then 3 spaces everywhere. 1s/^/ /;s/^/ /
Answered By - KamilCuk Answer Checked By - Dawn Plyler (WPSolving Volunteer)