サブシェルで中括弧を含むgrep --includeが失敗するのはなぜですか? [コピー]

サブシェルで中括弧を含むgrep --includeが失敗するのはなぜですか? [コピー]

これはシェルで動作します。

grep -R --exclude-dir=storage --exclude-dir=node-modules --include=*.{scss,css} loader.gif

しかし、これは失敗します。

sh -c "grep -R --exclude-dir=storage --exclude-dir=node-modules --include=*.{scss,css} loader.gif"

メッセージなしで失敗し、何も起こりません。

これは働きます:

sh -c "grep -R --exclude-dir=storage --exclude-dir=node-modules --include=*.scss loader.gif"

中かっこの使用--include=*.{scss,css}が失敗するのはなぜですか?

ベストアンサー1

これはおそらく、あなたのshPOSIX shが通常のPOSIX sh(または少なくともログインシェルよりも簡単です)であり、中かっこ拡張がサポートされていないためです。 Linux システムでは、少なくとも Debian と Debian がデフォルトです。Ubuntu。 Bashを実行するには実行してくださいbash -c

おすすめ記事