Oct 12, 2015, 7:51 AM
Post #1 of 5
I am trying to grep for a variable with patterns in a file.
grep file for lines contained in variable
So blist (a variable) contains this pattern:
etc. there are about 20 lines.
I want to run a script to grep for each line above in the listfiles.txt.
So like this in bash one line statements:
cat listfiles.txt |grep CORPORATE-EXPENSE-LIST
Then the list is searched again:
cat listfiles.txt |grep CORPORATE-FUNDING-SCHEDULE
open my $fh, '<', '/tmp/listfiles.txt' or die "unable to open file '$file' for reading : $!";
my @arr = <$fh>;
close $fh; # close
my @lines = grep /$blist/, @arr;
I am not able to make the search happen. Can someone give pointers?
The variable only prints out the patterns it contains but the grep doesn't work. So I just get:
(This post was edited by regex2012 on Oct 12, 2015, 7:51 AM)