当前位置: 技术问答>linux和unix
初学shell编程,请教大家一个问题
来源: 互联网 发布时间:2016-01-19
本文导语: #!bin/bash #This is my first test,Good luck! read name if [ test $name=xxxx ] then echo "You are my owner" elif [ test $name=xx] then echo "Loving you" elif [ test $name=x ] then echo "hahaaha" else ...
#!bin/bash
#This is my first test,Good luck!
read name
if [ test $name=xxxx ]
then
echo "You are my owner"
elif [ test $name=xx]
then
echo "Loving you"
elif [ test $name=x ]
then
echo "hahaaha"
else
echo "$name"
fi
出现:bash: ./test.sh: bin/bash: bad interpreter: 没有那个文件或目录
的错误,请问是怎么回事阿?
#This is my first test,Good luck!
read name
if [ test $name=xxxx ]
then
echo "You are my owner"
elif [ test $name=xx]
then
echo "Loving you"
elif [ test $name=x ]
then
echo "hahaaha"
else
echo "$name"
fi
出现:bash: ./test.sh: bin/bash: bad interpreter: 没有那个文件或目录
的错误,请问是怎么回事阿?
|
估计应该是/bin/bash,你少了一个斜杠,系统就找不到bash这个可执行文件了。
|
你应该要么用test 要么用[]
不要两个都用
不要两个都用
|
if [ $name=yang ]
改为 if [ $name = yang ]
等号两边要留空格出来
改为 if [ $name = yang ]
等号两边要留空格出来
|
if [ $name=yang ] // if [ "$name" = "yang" ]
这样试试看
这样试试看