Better (but stiull unsafe) to remove the line using its contents than using a line number. If you want to delete a line whose contents are known:
sed -i /{contents}/d in.sh
Another solution is to use grep -v:
grep -v '{contents}' <in.sh >out.sh
In both cases {contents} is a regexp that matches the contents you want to remove, knowing that strings with only letters and numbers and a few select special characters are regular expressions for themselves, so:
sed -i /somefile/d in.sh
grep -v 'somefile' <in.sh >out.sh
will remove any line containing somefile
from the input. But keep in mind that they could also match more things (for instance somefile2
would also be matched) unless you start using more complete regexps, for instance using ^{contents}$
to match lines that are exactly {contents}
, excluding those that contain {contents}
and additional things.