Dear Ranga,
> I tried grep and egrep - they seem to match only one line at a time. I am
> unable to match for \n inside the pattern.
>
> What shell utility would do it? I dont want to bring in the perl
> interpreter just for this!
Please *do*!
If the perl invocation is your performance bottleneck, that is a
pleasant problem to deal with.
Bringing in the perl interpreter is not measurably more
expensive than bringing in the awk or sed interpreters.
======================\/========BEGIN=========\/======================
% echo a.b > a.b
% time perl -ne 'print if /a.b/' a.b
a.b
0.02u 0.01s 0:00.02 150.0%
% time grep a.b a.b
a.b
0.00u 0.01s 0:00.01 100.0%
% time awk '/a.b/' a.b
a.b
0.00u 0.01s 0:00.01 100.0%
% time sed 's/a.b/a.b/' a.b
a.b
0.00u 0.00s 0:00.02 0.0%
%
======================/\=========END==========/\======================
Even perl 4.x is better than sed or awk. 4.x does not have the /s
modifier, but we can get around it with "[\w\W]".
======================\/========BEGIN=========\/======================
% /depot/perl-4.036/bin/perl -wle \
'$_ = "a\nb"; print 1 if /a.b/; print 2 if /\nb/; print 3 if /a[\w\W]/'
2
3
% /depot/perl-4.036/bin/perl -e '/a.b/s'
Substitution pattern not terminated in file /tmp/perl-eOEaiQl at line 1, next
char ^?
syntax error in file /tmp/perl-eOEaiQl at line 1, next 2 tokens "/a.b/s
"
Execution of /tmp/perl-eOEaiQl aborted due to compilation errors.
%
======================/\=========END==========/\======================
peace, || What can one hour achieve?
--{kr.pA} || http://www.workanhour.com/
--
Kid, n.: A noise with dirt on it.
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm