perl one liner
Posted on 2006-06-19
I have a file that has groups of lines, I need to print out certain groups of lines if they contain a key word.
I usally do this with a one liner like.
perl -n00e 'print if /key_word/i' file1.txt
I need to do the same thing but use a text file that contains a long list of key words, how do I make x=(the key_words in file1.txt) then do something like
perl -n00e 'x=(key words in file1.txt;print if /$x/i' file2.txt
I tried something crazy like this but it prints out everything, not even close to what I'm trying to do.
for i in file1.txt; do perl -n00e 'print if /$i/i' file2.txt; done