![](/img/trans.png)
[英]How to get full path from “../” on command line in Linux shell script
[英]Launch Bash script with command line and full path
我通常使用 ./ 命令啟動 bash 腳本。
但是,如果我嘗試使用完整路徑啟動腳本,則會出現錯誤
無此文件或目錄
我很困惑,我進行了搜索以確保找到正確的路徑。
$ pwd
/home/pi/server/
$ ls
start_scan
$ sudo chmod 777 start_scan
$ sudo find / -xdev -name start_scan
/home/pi/server/start_scan
$ ./home/pi/server/start_scan
-bash: ./home/pi/server/start_scan: No such file or directory
你知道問題是什么嗎? 我正在使用 macbook 使用 SSH 並連接到 Raspbian 下的 Rapsberry Pi 並在那里執行腳本。
./
不是命令,而是表示當前工作目錄的路徑。
您的行幾乎是正確的,只需刪除開頭的點:
/home/pi/server/start_scan
當您鍵入以點開頭的任何路徑時,shell 會將其擴展到當前工作目錄,從而有效地搜索
/home/pi/server/home/pi/server/start_scan
這顯然是錯誤的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.