I am trying to comment the lines in my scripts where a pattern from a given list of patterns is present. Now, I am able to do it the following way on command line :
sed '/abcdefg/ s/^/#/' file.sql > file.commented
But if I use a variable for pattern (instead of abcdefg directly as above) I'm not able to do the same.
pattern=abcdefg
sed '/$pattern/ s/^/#/' file.sql > file.commented
Looks like it is escaping the dollar character and not taking the value of the variable.
How do you do the same with awk?