問題: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
