Hi,
This is my text file I'm trying to Grep.
Apple Location Greenland Rdsds dsds fdfd ddsads http Received Return Immediately Received End
My Grep command:
grep only--matching 'Location.*Received'
Because the keyword Received appears twice, the Grep command will stop at the last one:
Location Greenland Rdsds dsds fdfd ddsads http Received Return Immediately Received
I want it to stop after the first one:
Location Greenland Rdsds dsds fdfd ddsads http Received
How is that possible?
Thanks
With awk ...perhaps a solution...
cat file | awk -F "Received" '{print $1,"Received"}'
I don't believe grep is intended to do such a thing, but something like this
perl -pe 's/.*(Location.*?Received).*/$1/' your_file
can.
edit:
Well i was wrong: grep could, though
man grep says -P --perl-regexp
Interpret PATTERN as a Perl regular expression. This is highly experimental and grep -P may warn of unimplemented features
and in deed, Debian GNU/Linux says:
grep: Support for the -P option is not compiled into this --disable-perl-regexp binary