sudo find / -name "*" | xargs grep -sn --color=auto "-j"
上記のコマンドは以下に戻ります:
grep: invalid option -- 'j'
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
...
文字列-jを検索するにはどうすればよいですか ?
承認された回答:
あなたの場合、"-j" grepによって解釈されます あなたがそれを引用したとしても、検索パターンとしてではなく、引数/オプションとして。検索したいもののパターンにするには、-eを使用するだけです。 オプション:
sudo find / -name "*" | xargs grep -sn --color=auto -e "-j"
または:
sudo find / -name "*" | xargs grep -sn --color=auto -e -j
-e 引数/オプションは、次の引数がパターンであることを意味します。これはman grepからのものです :
-e PATTERN, --regexp=PATTERN
Use PATTERN as the pattern. This can be used to specify
multiple search patterns, or to protect a pattern beginning with
a hyphen (-). (-e is specified by POSIX.)
その他の方法:
-
--を使用する 、@ Rinzwindが彼の答えで言ったように、grepを作成する オプションが終了したことを知るために。 -
を使用する ハイフンをエスケープするには(--):sudo find / -name "*" | xargs grep -sn --color=auto "-j"