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


问题: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 

 

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM