shell脚本的read -p写法
一个脚本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怎么会打印出呢?
谢谢!
[解决办法]
小伙子,你最好貌似没有加引号吧,我的执行结果如下:
[root@node2 ~]# sh aaaaaa.sh
Please input your first name: zhu
Please input your last name: ying
Your full name is: zhu ying
[解决办法]
最后一行的行尾少了个双引号
什么系统?
[解决办法]
test.sh
#!/bin/bash
for ((i=1;i<=3000))
do
touch $i.txt
done