好吧,这很可能听起来像是一个愚蠢的问题,但我无法让它工作,真的不知道我在这里做错了什么,即使在阅读后不少NAWK/awk的帮助网站:“nawk if else if else”不工作
$ echo -e "hey\nthis\nworld" | nawk '{ if ($1 !~ /e/) { print $0; } else if ($1 !~ /o/) { print $0; } else { print "condition not mached"; } }'
hey
this
world
$
我更愿意把它在同一行,但也试过上所看到的各种例子多行:
$ echo -e "hey\nthis\nworld" | nawk '{
if ($1 !~ /e/)
print $0;
else if ($1 !~ /o/)
print $0;
else
print "condition not matched"
}'
hey
this
world
$
感谢您帮助一个nawk-新手!
我只是想只打印不包含特定图案的线,这里是“e”或“o”。 我只为测试目的添加了最后的其他部分。
谢谢埃尔! 现在我看到了我在if结构中的误解。 – hermann 2014-09-05 14:18:38