shell中的read

使用read读入变量赋值shell

    参数bash

            -p    设置提示信息ide

            -t    设置超时时间
ip

使用方法:input

    [root@shell script]# read -p "pls input :" n
    pls input :12
    [root@shell script]# echo $n
    12

特殊用法
it

[root@shell script]# cat jisuan.sh 
#!/bin/bash
read -t 10 -p "Pls input :" a b
echo "a+b=$(($a+$b))"
[root@shell script]# sh jisuan.sh 
Pls input : 12 12
a+b=24
相关文章
相关标签/搜索