Title: perl sed like operations.... was RE: [Perl-unix-users] perl equivalent to "cut"

Thanks for all the excellent examples, I learned a whole lot more than I bargained for.
I am currently working on converting korn scripts that I have written over to PERL
for the experience. The following has me stumped, dealing with a sed conversion I am
attempting:

example:
$ echo "a test line to grep and return specific pattern only" | sed -n -e '/test.*to.*grep/s/.*\(test.*grep\).*/\1/p'
test line to grep

with the above, in a case where many strings are similar but not exact in a file, this sed command saved the exact pattern from the first sed search output.  Kinda like two seds in one.

so in conclusion, the following echo would not return a line as ~expected~:
$ echo "a test line for grep functions" | sed -n -e '/test.*to.*grep/s/.*\(test.*grep\).*/\1/p'

Now the question is how do I do the similar with Perl ?
TIA for bearing with me =).

Reply via email to