LoginSignup
2
0

More than 1 year has passed since last update.

grep,wcコマンドで、特定の文字列(もしくは文字)の個数を数える(カウントする)

Posted at

grep,wcコマンドで、特定の文字列(もしくは文字)の個数をカウントするやり方についてです。

$ cat hoge.txt
rw
wetoaw""
rw'ajo
rww
'"
hoge"

$ # rwの数をカウントする
$ grep -io rw hoge.txt | wc -l
       3

$ # "の数をカウントする("は\でエスケープしている)
$ grep -io \" hoge.txt | wc -l
       4

$ # 'の数をカウントする('は\でエスケープしている)
$ grep -io \' hoge.txt | wc -l
       2

参考サイト
Linux テキスト内の文字列の数をカウントするコマンド

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0