Linux命令,如何查看一个字符在字符串中出现的次数:‘asdefedgwe' 查看...
发布网友
发布时间:2024-10-20 13:29
我来回答
共2个回答
热心网友
时间:2024-11-09 12:54
echo "asdefedgwe" | grep -o 'e' | wc -l
echo "asdefedasdfasdfagwe" | tr -dc 'e' | wc -m
echo "asdefedgwe" | awk '{s+=gsub(/e/,"&")}END{print s}'
echo "asdefedasdfasdfagwe" | awk -v RS="e" 'END{print NR-1}'
echo "asdefedasdfasdfagwe" | sed -n 's/./&\n/gp' | sed -n '/e/p' | wc -l
echo "asdefedasdfasdfagwe" | awk -F'e' '{print NF-1}'
热心网友
时间:2024-11-09 12:58
呃~~~你不如自己编个小程序实现,用linux就应该学着编程