Linux命令,如何查看一个字符在字符串中出现的次数:‘asdefedgwe' 查看e出现的次数?

大神有没有人讲详细点的,我想教一下,Linux命令,如何查看一个字符在字符串中出现的次数:‘asdefedgwe' 查看e出现的次数?
最新回答
姐の霸气

2025-02-25 01:52:19

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}'
国产祖宗

2025-02-25 00:37:31

呃~~~你不如自己编个小程序实现,用linux就应该学着编程