Bash: how not to print first or last N lines of a file
Assume we have the following file named file.txt
Assume we have the following file named file.txt
aaa
bbb
ccc
ddd
eee
fff
ggg
hhh
iii
kkk
lll
mmm
nnnNot to print the last 3 lines use the head command with a negative integer number as input
cat file.txt | head -n -3
aaa
bbb
ccc
ddd
eee
fff
ggg
hhh
iii
kkkNot to print the first 3 lines use the tail command like this, with the plus symbol
cat a.txt | head -n -3 | tail -n +4
ddd
eee
fff
ggg
hhh
iii
kkkEasy right? :) i hope you liked those super simple and sort examples, see you next time!