I have been using Linux env and recently migrated to solaris. Unfortunately one of my bash scripts requires the  use of grep with the P switch [ pcre support ] .As Solaris doesnt support the pcre option for grep , I am obliged to find another solution to the problem.And pcregrep seems to have an obvious  loop bug and  sed -r option is unsupported !
I hope that using perl or nawk will solve the problem on solaris.
I have not yet used perl in my script and am unware neither of its syntax nor the flags.
Since it is pcre , I beleive that a perl scripter can help me out in a matter of minutes. They should match over multiple lines . 
Which one would be a better solution in terms of efficiency the awk  or the perl solution ?
Thanks for the replies .
These are some grep to perl conversions you might need:
grep -P PATTERN FILE(s)   --->  perl -nle 'print if m/PATTERN/' FILE(s)
grep -Po PATTERN FILE(s)  --->  perl -nle 'print "$1\n" while m/(PATTERN)/g' FILE(s)
That's my guess as to what you're looking for, if grep -P is out of the question.
Here's a shorty:
 grep -P /regex/ ====> perl -ne 'print if /regex/;'
-n takes each line of the file as input. Each line is put into a special perl variable called $_ as Perl loops through the whole file.-e says the Perl program is on the command line instead of passing it a file.print command automatically prints out whatever is in $_ if you don't specify for it to print out anything else.if /regex/ matches the regular expression against whatever line of your file is in the $_ variable.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With