I want to shorten a log file on a unix system with very limited shell capability. My preferred way to do this would be with ed
.
Deleting a fix number of lines works fine:
ed -s file.txt <<< $'1,4d\nwq'
But how can I expand the number of lines to delete from a shell variable in a ed
oneliner? I'm looking for something like:
n_del=4; ed -s file.txt <<< $'1,\${n_del}d\nwq'