Hello,
may I ask if it is possible to get grep.exe to return only result of seach pattern and not any (complete) lines which contain the seacht pattern?
(I'm using Gnu Grep V2.5.4 for Windows 7)
Thanks for any hint.
Regex search with grep: How to get only search pattern as result and not whole line?
Moderator: DosItHelp
Re: Regex search with grep: How to get only search pattern as result and not whole line?
Of course. And if this question is related to your first thread then it might work like that:
Steffen
Code: Select all
grep -P "\bA_[A-Za-z\d]+_f[ ]*\([ ]*[-]*[\d.]+[ ]*\)" -o "test.txt"
Steffen
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Regex search with grep: How to get only search pattern as result and not whole line?
I seem to recall grep having a -o flag that only returned the matching part.
EDIT: Yep, -o. https://www.gnu.org/software/grep/manua ... ut-Control
EDIT: Yep, -o. https://www.gnu.org/software/grep/manua ... ut-Control