$ echo "hello world hello hell" > hello.txt
$ grep -o 'h' hello.txt
h
h
h
$ grep -o 'h' hello.txt |wc -l
gawk -F "" '{for(i=1; i<=NF; i++) if($i=="h")++sum}END{print sum}' hello.txt
cat hello.txt |tr -dc 'h' |wc -c
3
ello world ello ell
cat hello.txt |tr -dc 'h'
hhh
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |