
Laurent_R
Veteran
/ Moderator
Dec 20, 2012, 10:19 AM
Post #4 of 4
(3033 views)
|
Re: [LDHB2012] script to create multiple files off multiple grep strings
[In reply to]
|
Can't Post
|
|
Yes, it can be done and Perl is a good candidate language to do it. To find all the files in the directory and keep only those that are less than 7 days old, you could do something like this:
my @file_list = glob "/data/2012_data/*.*"; @file_list = grep { -M $_ < 7} @file_list; to read your config file:
my $config = "config.txt"; open $CONF, "<", $config or die "cannot open $config $! \n"; my ($string, $file_name); while (my $line = <$CONF>) { chomp $line; ($string, $file_name) = split /;/, $line; # assumes string to be grepped and filename are separated by a semi-colon # etc. } I hope thse code snippets will help you starting, but you'll need to do some work of your own. You will probably need to nested loops: one to loop opn the strings to be grepped, and another to loop through your data, and this last loop mlight itseld be two nested loops: one to loop through the lmist of files and one to loop though the lines of each file. You'll neeed careful polanning.
|