Extract lines between two line numbers in shell
Using sed:
$ cat my_file_path | sed -n "${line1},${line2}p"
or, even better (cat
is somehow redundant):
$ sed -n "${line1},${line2}p" my_file_path
You can use a pipe with tail and head
tail -n +$line1 | head -n $((line2-line1))