此脚本尝试将文本文件复制到另一个目录中。 我不明白为什么我会遇到这个问题: ./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 的原因,并且我对它们进行均衡。
最佳答案
您正在使用 PATH=$PATH 删除 $PATH: ls 不是内置命令,因此它必须位于 PATH env 中
关于linux - ls: 未找到命令 BASH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40028882/