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 モードが 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