read.sh

398 ワード

#readを使用して3つのパラメータを3つの変数に割り当てます.
[root@hbase1 k]# cat read.sh 
#!/bin/bash
read -p "Please enter three parameters, respectively:" a b c 
echo $a
echo $b
echo $c

[root@hbase1 k]# ./read.sh 
Please enter three parameters, respectively:one two three
one
two
three
[root@hbase1 k]#

3つのパラメータone two threeを入力すると、それぞれa b cに割り当てられます.echoで$a$b$cを入力すると、それぞれの割り当てが表示されます.