我有一個包含一個小的測試文件:awk中具有可變和否定多個搜索字詞
awk this
and not awk this
but awk this
so do awk this
我累了,下面的awk命令,在bash,但每次不產生輸出:
f=awk; awk '/$f/ && !/not/' test.txt
f=awk; awk '/\$f/ && !/not/' test.txt
f=awk; awk '/"$f"/ && !/not/' test.txt
f=awk; awk -v f="$f" '/f/ && !/not/' gtest.txt
由於!
,使用雙引號"
在shell中產生「event not found」錯誤。
如何搜索變量並在相同的命令中否定另一個字符串?
謝謝!我認爲這會做到。 –