【发布时间】:2017-02-23 01:01:46
【问题描述】:
此脚本尝试将文本文件复制到另一个目录。 我不明白为什么我会遇到这个问题: ./move_in.sh:第 36 行:ls:找不到命令 在我添加 if 语句之前它工作正常。
update_file=pwd
echo ""
echo "You can move a text file from your PC into the repository"
echo ""
echo "You need to know where is your text file"
cd /
ls
times=1
echo ""
echo "Where is your text file?"
read directory
while [ -d $directory ]
do
echo $times
if [ $times == 1 ]
then
LAST=$directory
fi
if [ $times != 1 ]
then
LAST=$PATH/$directory
fi
cd $directory
ls
echo ""
echo "Where is your text file?"
read directory
PATH=$LAST
echo $PATH
times=$((times + 1))
done
PATH=$PATH/$directory
echo $PATH
open $PATH
cp $PATH /\$update_file
echo "You found the text file!"
exit 0
我想在进程完成时获得文件的完整路径,这就是我使用 LAST 和 PATH 的原因,并且我将它们均衡化。
【问题讨论】: