.shファイルからシェルコマンドを実行するとエラーが発生します。

.shファイルからシェルコマンドを実行するとエラーが発生します。

次の2つのLinuxシェルコマンドがあります。

echo 'CPU type and model'
cat /proc/cpuinfo | head -5 | tail -1

端末から直接このコマンドを実行すると、実際には次の結果が表示されます。

CPU type and model
model name  : Intel(R) Core(TM) i3 CPU       M 330  @ 2.13GHz

test.shただし、ファイルに保存して実行すると、sh test.sh次のエラーが発生します。

CPU type and model
tail: option used in invalid context -- 1

私もbash test.shこれを手に入れようとしました。

CPU type and model
tail: option used in invalid context -- 1

ベストアンサー1

スクリプトファイルには、キャリッジリターンとdos2unixそれを削除するために使用できる他の無関係な文字が含まれています。

おすすめ記事