>>496
こういう場合、ed を non-interactive に使うのがいい。

最後20行ということは、$-19から $までだから、

echo '$-19,$d
w outfile
q' | ed infile

↑で桶。