Posts by jhnc
To delete $n lines in-place (won't break hard-links): printf ',$-%dw\n' $n | ed -s file Exits with a non-zero value if the change failed (e.g. not enough lines in file).
Inasmuch as ed is the standard editor, you could do: ed -s "$file" <<EOD 1c $env . w EOD or: printf '%s\n' 1c "$env" . w | ed -s "$file" If the first line might not be a shebang,...
