July 2022 mac os Monterey V12.1
awk --version 20200816
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)
为什么awk -F
对大多数字母有效,但对字母无效t
?我有解决方案,但我想了解为什么 awk 对 letter 失败t
。
# Count 'e's
% echo "tweeter" | awk -F "e" '{print NF-1}'
3
# Count 'r's
% echo "tweeter" | awk -F "r" '{print NF-1}'
1
# (Attempt to) count 't's
% echo "tweeter" | awk -F "t" '{print NF-1}'
0 <=== ????
# Use gsub()
% echo "tweeter" | awk '{print gsub(/t/, "")}'
2