问题截图:
一开始,我以为是权限的问题,root之后仍然报错
解决方法:
我解决这个问题分了两步
1.修改了/bin/bash执行方式:
ls -l `which sh`
会发现脚本默认是以dash模式执行的,此时运行:
dpkg-reconfigure dash
就会出现:
2.做完上述步骤,仍然报错,此时便要考虑是脚本本身格式问题。我是从Win10主机复制到虚拟机里面的,于是进行如下操作
安装dos2unix组件
apt install dos2unix
对.sh脚本进行格式转换
chmod 755 your_script.shdos2unix your_script.sh
做完这些后,就可以正常source我们的.sh脚本了
参考链接:
/p/44d659fcbf09
/Together_CZ/article/details/88395718?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight