sed how to delete first 17 lines and last 8 lines in a file sed how to delete first 17 lines and last 8 lines in a file bash bash

sed how to delete first 17 lines and last 8 lines in a file


head and tail are better for the job than sed or awk.

tail -n+18 file | head -n-8 > newfile


awk -v nr="$(wc -l < file)" 'NR>17 && NR<(nr-8)' file


All awk:

awk 'NR>y+x{print A[NR%y]} {A[NR%y]=$0}' x=17 y=8 file