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