I am trying to write a script (.awk) that will print out lines that contain a certain string between lines 7-13. I have it partially working however it prints out all lines that contain the string rather than only between 7-13.
#!/usr/bin/awk -f
BEGIN { (NR>=7) && (NR<=13) }
/word/ {print $0}
the output when running
script.awk filename
is all lines that contain the word
edit:
After trying out what jeff suggested, I get this with his suggestion. /needle/ being the keyword.
The issue was that I had {print $0} on another line, used to it in other languages where I like to separate my code out