我在工作中经历了一些简单的bash脚本,这是其他人在一个月前写的,我发现了这一行:
| awk -F'AUTO_INCREMENT=' 'NF==1{print "0";next}{sub(/ .*/,"",$2);print $2}'
有人可以帮助我用简单的词语解释这一行。谢谢!
答案 0 :(得分:2)
awk -F'AUTO_INCREMENT=' ' # Set 'AUTO_INCREMENT=' as a field separator
NF==1 { # If number of fields is one i.e. a blank line
print "0"; # print '0'
next # Go to next record i.e. skip following code
}
{
sub(/ .*/,"",$2); # Delete anything after a space in the second field
print $2 # Print the second field
}'
示例强>
示例输入
AUTO_INCREMENT=3
AUTO_INCREMENT=10 20 30 foo bar
输出
3
0
10