echo "enter file name"
read a
echo "enter directory name"
read b
if [ -f $a ]
then
if [ -d $b ]
then cp $a $a/$b
echo "file copies"
else echo "directory not exit"
fi
else echo "file not exit"
fi
执行结果是file not exit。输入什么都这么显示
输入错误的文件名,显示如下:
[root@localhost ~]# sh test2
enter file name
s
enter directory name
d
file not exit
输入正确的文件名,显示如下
[root@localhost ~]# sh test2
enter file name
wenj
enter directory name
dir1
file not exit