How to print only the previous 5th and 6th lines using the 'grep' command June 07, 2024 How to print only the previous 5th and 6th lines using the 'grep' command grep total -B 5 -w my.test | awk '( ((NR%7) == 1) || ((NR%7) == 6 )) { print $0 } ' | more Read more