I want to show the 3 first lines and the 2 last lines that contain a word. I tried a grep command but it's not showing what I want.
grep -w it /usr/include/stdio.h | head -3 | tail -2
It only display the 2nd and 3nd lines that contain "it" in it.
You can simply append the results of head and tail :
{ head -3 ; tail -2 ;} < /usr/include/stdio.h
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With