grep
オプションを参照するマニュアルを読むときに問題が発生しました-e
。
-e pattern, --regexp=pattern
Specify a pattern used during the search of the input: an input
line is selected if it matches any of the specified patterns.
This option is most useful when multiple -e options are used to
specify multiple patterns, or when a pattern begins with a dash
(`-').
混乱しています。略語とは何ですかe
? Google で回答が見つかりません。
しかも、わかりやすいです。
「このオプションは、複数の-eオプションを使用して複数のモードを指定する場合に最も便利です。」
しかし、これは何を意味しますか?
「または、パターンがダッシュ( `-')で始まる場合。」
例を挙げることができますか?
ベストアンサー1
-E
「eは表現を意味します」は、特に少なくとも一部のバージョンでは合理的な解釈ですgrep
。
複数の-e
フラグを使用して複数の式を一致させることができます。たとえば、次のようになります。
# grep -e "nodes" -e "routers" /etc/hosts
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
そして、パターンをオプション/フラグとして解釈しようとしないようにダッシュで-e
始まるパターンを許可します。grep
# grep -e "-all" /etc/hosts
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts