For sed - use double quotes around the variable.
For awk - use combination of double quotes single quotes double quotes
sed '/'"$pattern"'/d' filename
Another option is to enclose entire sed command in double quotes.
sed "/$pattern/d" filename
For awk - use combination of double quotes single quotes double quotes
awk '{ if ($(1) == "'"$pattern"'" ) {print $2}}'
Optionally, you could create an awk variable from shell variable.
awk '{ if ($(1) == ipattern ) {print $2}}' ipattern=$pattern filename
No comments:
Post a Comment