版权声明:本文系作者原创。未经许可,不得转载。

文件名为:try.txt
$ cat try.txt

The Younger Generation In the Twenty-first Century

  Good evening, ladies and gentlemen.

  We always say ‘we are the future’. Indeed. We, the younger generation represents modern knowledge, new concepts, ambiti and great desire for success. But, have you ever thought of this question: how can we be successful in the 21st century, which is full of great challenges and fierce competitions? In my opinion, there are two important factors.

脚本:
$ cat try.txt | xargs echo | awk '{gsub(/[^a-zA-Z0-9 -]/, "");print $0}' | awk 'BEGIN{i=0;j=0}{while(j<NF){j++;if($j~/^[gG]/) i++}}END{print i}'

注意事项:
1、全角字符、换行符、空格符等的转换。
2、将竖排的文件变成一行输出。

lansheng228
256 声望4 粉丝

引用和评论

0 条评论