The title says all. I tried several syntax, all failed. Maybe this is not possible with a single shoot... Of course, search engines didn't help, nor the manual that is difficult to understand, nor the info command. All lack an example with a range of "kind of" preselection
AWK , too:
bash-4.3$ cat input.txt line one and another line running out of ideas for text Oh, look , banana ! some more lines this is boring But what is not boring ? text processing ! bash-4.3$ awk 'NR<4; NR>4 && $0!~/banana/' input.txt line one and another line running out of ideas for text some more lines this is boring But what is not boring ? text processing !
The idea here is to print all lines that are less than 4 untouched. Lines greater than 4 that do not contain specific pattern ( in this case the word "banana" ) , will be printed, and obviously those that do contain it won't be printed.