Linux端末のファイルの内容から特定のキーワードや用語のカウントを取得する方法は?
Originally posted here!
ファイルの内容から特定のキーワードや用語の数を得るには、
内容の例
あなたが見ることができるように
上記コマンドの実行を見てくださいrepl.it .
それで😃!
ファイルの内容から特定のキーワードや用語の数を得るには、
cat
コマンドpath
ファイルに|
演算子( aka pipe operator )grep
コマンド、次に検索したいキーワード-c
Linux端末のフラグ( count flags )TLドクター
# Get the count of a specific
# word from the contents of a file
cat <PATH_TO_FILE> | grep <YOUR_SEARCH_TERM> -c
例えば、ファイルを持っているとしましょうmyFile.txt
以下のような内容があります.内容の例
Wikipedia is a free content, multilingual online encyclopedia
written and maintained by a community of volunteer contributors
through a model of open collaboration, using a wiki-based editing system.
Wikipedia was launched on January 15, 2001, by Jimmy Wales
and Larry Sanger; Sanger coined its name as a blending of "wiki" and "encyclopedia".
Initially available only in English, versions in other languages were quickly developed.
Its combined editions comprise more than 57 million articles,
attracting around 2 billion unique device visits per month,
and more than 17 million edits per month (1.9 edits per second).
今、我々は特定の単語が発生した回数や単語の数を見つけたいWikipedia
の内容からmyFile.txt
ファイル.我々はそれを使用することができますcat
and grep
コマンド# Get the count of a specific
# word from the contents of a file
cat myFile.txt | grep Wikipedia -c
上記のコマンドを実行する出力はこのようになります.あなたが見ることができるように
Wikipedia
カウントする2
上記の出力で.上記コマンドの実行を見てくださいrepl.it .
それで😃!
お気軽に共有する場合は、この便利な発見😃.
Reference
この問題について(Linux端末のファイルの内容から特定のキーワードや用語のカウントを取得する方法は?), 我々は、より多くの情報をここで見つけました https://dev.to/melvin2016/how-to-get-the-count-of-a-specific-keyword-or-term-from-the-contents-of-a-file-in-the-linux-terminal-3hh6テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol