I tried the following snippet in a shell script but awk didn’t find $REF
REF=SEARCH_TEXT
echo "some text" | awk '/$REF/{print $2}'
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.
You question is worded really poor…
Anyway, I think you want this:
Note the escaping of
$2and the double quotes.or this:
Note the judicious use of double and single quotes and no escaping on
$2.You have to use shell expansion, as otherwise it would encompass exporting a shell variable and using it from the environment with awk – which is overkill in this situation:
I think awk does not support variables in /…/ guards. Please correct me if I’m wrong.