ls:命令未找到BASH

时间:2016-10-13 18:58:06

标签: linux bash shell ls

此脚本尝试将文本文件复制到另一个目录中。 我不明白为什么我遇到这个问题: ./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的原因,并且我将它们均衡。

1 个答案:

答案 0 :(得分:1)

您正在删除$ PATH使用PATH = $ PATH: ls不是内置命令,因此必须在PATH环境中