Loading

如何使用 Shell 命令在 linux 当中统计很多文件当中所有的中文字符

grep -P '[\p{Han}]+' **/*.md -oh | tr -d '\s' > cat.log

-P 是正则表达式匹配

-h, --no-filename
Suppress the prefixing of file names on output. This is the default
when there is only one file (or only standard input) to search.

-o, --only-matching
Print only the matched (non-empty) parts of a matching line,
with each such part on a separate output line.

posted @ 2023-12-28 14:54  ZXYFrank  阅读(23)  评论(0编辑  收藏  举报