ubuntu sh ???.sh 时出现 let: not found
(我的sh文件里有mv命令,结果文件全丢失了)
出现问题的原因:It's because Ubuntu uses the dash shell as default and doesn't always recognize when you try to set the shell in a script. Even if you enter "echo $SHELL" into the console it will tell you you're using /bin/bash but for some reason it's actually using dash instead.
#就是bash环境指向了/bin/sh,而在/bin/bash里才有let命令。
解决办法:
sudo dpkg-reconfigure dash
<password>
and when you get the option select"no" to actually use bash instead of dash
其实也可改用 bash ???.sh指令
(我的sh文件里有mv命令,结果文件全丢失了)
出现问题的原因:It's because Ubuntu uses the dash shell as default and doesn't always recognize when you try to set the shell in a script. Even if you enter "echo $SHELL" into the console it will tell you you're using /bin/bash but for some reason it's actually using dash instead.
#就是bash环境指向了/bin/sh,而在/bin/bash里才有let命令。
解决办法:
sudo dpkg-reconfigure dash
<password>
and when you get the option select"no" to actually use bash instead of dash
其实也可改用 bash ???.sh指令
本文探讨了在Ubuntu环境下使用dash shell作为默认shell时,sh脚本中出现let:not found错误的原因及解决方案。通过修改dpkg配置,可以确保使用bash环境,从而在sh文件中正常执行let命令,避免文件丢失等问题。
409

被折叠的 条评论
为什么被折叠?



