Skip to main content

Thread: A question for awk gurus :)


let's suppose have file this:
code:
...  foo  ...  bar  ...
where "..." number of lines text. following simple command outputs between "foo" , "bar":
code:
awk '/^foo/{i++;next}/^bar/{exit}i' file
i understand how works. if wanted skip couple of lines after "foo" well? (of course can pipeline tail -n +3 that's not interesting. ;)

i think can use getline read , throw away lines after foo. e.g.:

code:
  awk '/^foo/{i++;getline;getline;next}/^bar/{exit}i' file


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] A question for awk gurus :)


Ubuntu

Comments