Possible Duplicate:
extract regexp result from string and write it to a variable
Here is my command :
grep -E '\*[[:space:]]+FIN[[:space:]]+([^)]+?)') myfile
It outputs :
- FIN (SUCCESS)
And I would like it outputs only :
SUCCESS
How can I tell grep
to do it ?
You can pipe the output of your grep command to the awk command.
grep -E '*[[:space:]]+FIN[[:space:]]+([^)]+?)') myfile | awk '{print $2}'
I am not sure how to do that with grep alone, as it is not really tailored to that exact use case. Since you are on a platform where grep is, use pipes to your advantage when you can have one command solve part of the problem, and another command the other part.
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