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.
検索に使用した用語の最初のインスタンス (大文字と小文字を区別しない) のみを返したいのですが (一致する場合)、どうすればよいですか?
例:
$ grep "exactly-this" Binary file /Path/To/Some/Files/file.txt matches
次のような結果を返したいと思います。
$ grep "exactly-this" exactly-this
grep にはカウント引数が組み込まれています
オプションを使用して、-mgrep に count 引数を与えることができます
-m
grep -m 1 "exactly-this"
バイナリファイルの場合にメッセージを回避したい場合は、
grep -a -m 1 "exactly-this"
これにより、一致が発生した が出力されることに注意してください。これはwordバイナリ ファイルであるため、word複数の行にまたがる場合があります。
word