So I found a great awk line to search for a pattern and then print the N record after it.
iii) Print the N records after some pattern:
Code:
awk 'c&&!--c;/pattern/{c=N}' file
It's really hard to understand though with the c&&c.
How can I instead of printing the Nth record, delete it?
For example, I have a txtfile:
List of Names
Bob
Janet
Harry
List of Groups
Family
Party
Coworkers
If I do awk 'c&&!--c;/List of/{c=2}' txtfile
It will print:
Janet
Party
Instead of print, how can I delete them? I know with sed I can do
Code:
sed -n '/List of/{n;n;d;}' file
But the number of n's needs to be a variable as I have numerous records.
Thanks!!!