+ -
当前位置:首页 → 问答吧 → shell脚本的read -p写法

shell脚本的read -p写法

时间:2011-10-24

来源:互联网

一个脚本sh02.sh是:
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
read -p "Please input your first name: " firstname
read -p "Please input your last name: " lastname
echo -e "\nYour full name is: $firstname $lastname
但执行时提示sh02.sh: -p: is not an identifier
我直接在unix中敲read -p "Please input your first name: " firstname没有问题,请问是脚本哪里不对?

另外,当仅执行echo -e "\nYour full name is: $firstname $lastname时显示一个:
-e
Your full name is: 
这里-e怎么会打印出呢?

谢谢!

作者: bisal   发布时间: 2011-10-24

小伙子,你最好貌似没有加引号吧,我的执行结果如下:
[root@node2 ~]# sh aaaaaa.sh 
Please input your first name: zhu
Please input your last name: ying

Your full name is: zhu ying

作者: zhuying_linux   发布时间: 2011-10-24

最后一行的行尾少了个双引号
什么系统?

作者: ljc007   发布时间: 2011-10-24

test.sh

Assembly code
#!/bin/bash
for ((i=1;i<=3000))
do
    touch $i.txt
done


time ./test.sh

作者: ljc007   发布时间: 2011-10-24

热门下载

更多