当前位置: 技术问答>linux和unix
shell中echo最后面加入\c,还是存在回车换行现象
来源: 互联网 发布时间:2017-01-28
本文导语: 代码是实现copy功能,增加在执行cp的时候判断目标地址是否存在 then echo "usage:mycp from to" exit 1 fi from=$1 to=$2 if [ -e $to ] then echo "$to already exist ;overwrite(yes/no)?c" read answer if [ $answer...
代码是实现copy功能,增加在执行cp的时候判断目标地址是否存在
then
echo "usage:mycp from to"
exit 1
fi
from=$1
to=$2
if [ -e $to ]
then
echo "$to already exist ;overwrite(yes/no)?c"
read answer
if [ $answer != yes ]
then
echo "copy not performed"
exit 0
fi
fi
cp $from $to
执行后,现象是echo后面的c不生效,每次执行是还有回车换行
./mycp.sh test te
te already exist ;overwrite(yes/no)?c
请教下这个是什么原因?如何解决
then
echo "usage:mycp from to"
exit 1
fi
from=$1
to=$2
if [ -e $to ]
then
echo "$to already exist ;overwrite(yes/no)?c"
read answer
if [ $answer != yes ]
then
echo "copy not performed"
exit 0
fi
fi
cp $from $to
执行后,现象是echo后面的c不生效,每次执行是还有回车换行
./mycp.sh test te
te already exist ;overwrite(yes/no)?c
请教下这个是什么原因?如何解决
|
echo -e "$to already exist ;overwrite(yes/no)?c"
|
另外一个方法!
直接echo -n 就不会换行
直接echo -n 就不会换行
|
read -p "提示信息" answer
|
echo -e 'n'
echo -n