str is of the following pattern:
1 abc (1 <something>)
For example:
1 abc (1 hello)
1 abc (1 shalom)
1 abc (1 hola)
How could I extract <something> from str using egrep?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to extract just the
<something>then I’d suggestgrep -P(perl regex):The
-oreturns just the matched portion being<something>. The regex looks for text preceded by(1and followed by).You wouldn’t be able to do that with
egrepas it doesn’t support lookarounds. The best you’d do is extract the(1 <something>)with: