linux - ls: 未找到命令 BASH

标签 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 的原因,并且我对它们进行均衡。

最佳答案

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

关于linux - ls: 未找到命令 BASH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40028882/

相关文章:

linux - 从bash脚本获取特定设备的允许MTU范围

python - 无法使用 child.before 获取数据

bash - 如何将密码传递给 pg_dump?

linux - 悄悄地在脚本中更改 linux 密码

ruby-on-rails - 在 Capistrano 任务中启动后台进程

java - IOException 冒险

linux - 在 Docker compose 中限制可用的主机资源而不使用 swarm

vb.net - 在 VB.net 中获取 shell 命令的输出

linux - 使用 Linux 和 Windows 时最好的 git 配置设置是什么?

python - 如何制作一个虚拟视频设备用于测试和调试,其中有/dev/video9?