Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
bash スクリプトを実行したいとしましょう。読み取りを使用する代わりに、スクリプトが要求する値を指定するコマンドがターミナルにありますか?
たとえば、bash script1.sh と入力したときに、何らかの方法で値を入力してスクリプトに渡すことができますか、それとも最初に実行する必要がありますか。
bash script1.sh 3 4 のように
bash スクリプトのコマンド ライン引数にアクセスするには、$@配列と$0, $1, ...,$N値を使用します。
$@
$0
$1
$N
例えば:
#!/usr/bin/bash echo "First argument is $1" echo "Second argument is $2"