Trying to figure out how to store a list as a variable (array?) and use it in with awk.
I have a file like such:
Jimmy
May31
John
June19
Paul
Aug15
Mark
Sept1
David
Nov15
I want to use awk to search my file and remove three names and the line following each of those names. So the final file should only contain 2 names (and birthdays).
I can do this with:
awk '/Jimmy|Mark|David/{n=2}; n {n--; next}; 1' < file
But is there a way to store the "Jimmy|Mark|David" list in the above command as a variable/array and do the same thing. (The real project I've working on has a much longer list to match in a much bigger file).
Thanks!