Unix awk子串字符串比较

时间:2014-12-10 15:29:55

标签: unix awk

我想使用Unix AWK命令查找字符串中是否包含子字符串。

例如,伪代码:

a= commandline
b=line
if(b is contained in a)
  print "success " 

1 个答案:

答案 0 :(得分:2)

$ awk 'BEGIN{a="commandline";b="line";if (a ~ b){print "success"}}'
success