linux-source: not found ubuntu执行脚本报错

it2025-07-07  9

问题:Ubuntu系统执行shell脚本时报错

报错内容

linux-source:not found not found [[[

问题原因:在Ubuntu 当中 执行脚本默认的使用的是dash,而非bash,执行能力较弱

案例:

例如1.sh #!/bin/sh source /etc/profile 输出:source: not found 2.sh #!/bin/bash source /etc/profile 正常执行 3.source等价于 . 所以使用. /etc/profile都会执行正常 (注意点号后面空格)

测试:

 运行 ls -l /bin/sh 后显示/bin/sh -> dash 

ls -l /bin/sh

这说明是用dash来进行解析的。

解决方案:

命令行执行:

      dpkg-reconfigure dash(注意需要root权限),然后在界面中选择no 再运行ls -l /bin/sh 后显示/bin/sh -> bash

dpkg-reconfigure dash ls -l /bin/sh

重新执行脚本:问题解决!!

最新回复(0)