in reply to usage of awk and grep together
What operating system are you running this perl script on? What shell is being used by that operating system? When I run your command on using backtics on my system (Debian Linux, bash shell) I don't get an error at all.
If you need portability across operating systems, I recommend you stay away from backtics and pipes and instead use Perl functions. The following short script does the same thing as your grep/awk combination:
#strictures - put these two lines at the top of every Perl script #these do a lot of the debugging work for you use strict; use warnings; ... lots of other stuff ... # do: awk '/fileid/,/^-----/' logfile | grep specificdata my $bPrint=0; open LOGFILE, '<', "Monks/tmp/logfile.txt" or die; while (my $line = <LOGFILE>) { #equivalent to awk '/fileid/,/^-----/' logfile $bPrint = 1 if $line =~ /fileid/; $bPrint = 0 if $bPrint && $line =~ /^-----/; #equivalent to grep specific data print $line if $bPrint && $line =~ /specificData/; } close LOGFILE;
To learn more about the Perl concepts involved in the above code:
Best, beth
|
|---|