Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您如何计算<文件中的字符数?
<
我正在尝试计算文件中字符“<”的数量,就像在 Vim 中一样
%s/<//gn
我跑
find * -type f | xargs sed 's/<//gn'
我明白了
sed: -e expression #1, char 7: unknown option to `s'
这个错误提示我 Vim 的 :s -mode 不像 SED。
我不熟悉nVim 中的选项,但是是的,sed 不支持该n选项。<这是另一种计算文件中字符实例数的方法:
n
find * -type f | xargs cat | tr -d -c '<' | wc -c
该tr -d -c '<'命令删除所有不是 的字符,<然后wc -c计算剩余字符数。
tr -d -c '<'
wc -c
grep -RoE "<" * |wc -l