I want to print all the lines except the last three lines from the input through awk only. Please note that my file contains n number of lines.
For example,
file.txt
contains,
foo
bar
foobar
barfoo
last
line
I want the output to be,
foo
bar
foobar
I know it could be possible through the combination of tac
and sed
or tac
and awk
$ tac file | sed '1,3d' | tac
foo
bar
foobar
$ tac file | awk 'NR==1{next}NR==2{next}NR==3{next}1' | tac
foo
bar
foobar
But i want the output through awk only.