I have an issue in which my string its not a single string; it is a string with multiple words; in which using sed works great; but not with awk;
How can I group all that string with awk? I tried to encapsulate the string with " "
, with { }
, with ( )
and nothing works. Here is the example of my sed vs awk:
sed -n '/show system | inc Software/,/sh syst | i @@@@@/p' filename.txt > out_file.txt
That line works perfect with sed; the strings are "show system | inc Software"
and "sh syst | inc @@@@@"
As for awk it doesnt work.
awk '/show system | inc Software/,/sh syst | i @@@@@/' filename.txt > out_file.txt
The output file is not what I expect. How can I do that strings to work in that command?
awk
will use extended regular expressions, so the patterns will match lines with either side of the|
. You need to escape it as\|
to match a regular bar.