これら2つの同様のコマンドバリアントが異なる出力を提供するのはなぜですか?

これら2つの同様のコマンドバリアントが異なる出力を提供するのはなぜですか?

コマンド1:

$ rm hello.txt 2>/dev/null || { echo “Couldn’t delete hello.txt” }
"Couldn't delete hello.txt"

コマンド2

$ rm hello.txt 2>/dev/null || { echo 'Couldn’t delete hello.txt' }
Couldn't delete hello.txt

メモ: hello.txt現在のディレクトリには存在しません。

ベストアンサー1

最初のコマンド

rm hello.txt 2>/dev/null || { echo “Couldn’t delete hello.txt” }

<U+201C>(左二重引用符)、<U+2019>(右一重引用符)、および(右二重引用符)文字を含みます。これらの文字<U+201D>はシェルについて特別な内容がなく、そのまま出力されます。

2番目の順序

rm hello.txt 2>/dev/null || { echo 'Couldn’t delete hello.txt' }

一重引用符で囲まれた文字列を含みます。との間nの文字はシェルに特別ではありません。t<U+2019>

おすすめ記事