專業等級福利
• 在 Think 每日價格上節省高達額外 3%Plus 等級福利
• 在 Think 每日價格上節省高達額外 5%Lenovo Pro 商務採購商店
Lenovo Education 教育商店
官方專門店
Lenovo Pro 商務採購商店
Lenovo Education 教育商店
官方專門店
Lenovo Pro 商務採購商店
Lenovo Education 教育商店
官方專門店
Lenovo Pro 商務採購商店
Lenovo Education 教育商店
官方專門店
Lenovo Pro 商務採購商店
Lenovo Education 教育商店
官方專門店
Warranty Upgrade
PC Services
Data Center Services
Solutions
Support
使用 Lenovo Pro Business 帳戶購買任何 PC電腦,下張訂單購買選定配件時享高達 20% 折扣。
Lenovo 教育 | 註冊 Lenovo 教育,即刻解鎖高達 $800 迎新優惠及高達 8% 額外折扣。
有疑問嗎? 如需我們的專家建議,請致電 2593 0388或點擊「聊天」! 聯絡我們
ThinkPad X1 Carbon Gen 13 AI PC | 全新的 ThinkPad X1 Carbon Gen 13 AI 電腦現已上市。
新到貨品 | 探索我們最新的 Yoga、Legion、ThinkPad 與 IdeaPad 系列 立即選購
在計算中,「點斜線」指的是類 Unix 作業系統中用於執行目前目錄中的腳本或程式的「./ 」符號。點代表目前目錄本身,斜線是目錄分隔符號。因此,當您在腳本名稱前鍵入「./ 」時,您就是在告訴系統在目前資料夾中尋找該腳本,而不是在系統路徑中的任何位置。
是的,點斜線約定特定於類 Unix 系統,其中包括 Linux® 和其他 Unix 衍生版本。這些系統使用它來區分目前目錄中的可執行檔和位於系統路徑中的可執行檔。它不在 Windows 中使用,在 Windows 中您可以在沒有它的情況下運行當前目錄中的可執行檔。
如果要在目前目錄以外的目錄中執行腳本或程序,則不應使用點斜線。相反,您需要指定腳本的路徑。例如,要執行位於名為「scripts」的子目錄中的腳本,您需要鍵入不帶點斜線的「scripts/ myscript 」。點斜槓專門用於目前目錄中的某些內容。
如果您的命令沒有新增「./ 」前綴,且腳本或可執行檔位於目前目錄中,系統不會執行它,除非目前目錄位於路徑環境變數中。通常,出於安全原因,目前目錄不在路徑中,因此您需要使用點斜線來明確告訴 shell 執行此處的程式。
在程式設計中,尤其是在編寫 shell 腳本時,當您想要從正在編寫的腳本執行另一個腳本或程式時,您將使用點斜線。這是確保被呼叫的腳本從目前工作目錄運行的一種方法。因此,在類別 Unix 環境中編寫腳本時,這是正確理解和使用的重要約定。
如果您嘗試對未標記為執行檔的檔案使用點斜杠,系統會給您一個錯誤,通常類似於「權限被拒絕」。要運行帶有有點斜線的文件,您需要確保它具有執行權限,您可以使用chmod命令設定該權限。
是的,您可以將點斜線與相對路徑一起使用。例如,如果您位於一個目錄中並且想要執行子目錄中的腳本,則可以使用點斜杠,後跟腳本的相對路徑。就像“ ./subdir/myscript ” 。意思是「從目前目錄開始,沿著這個路徑尋找可執行檔」。
雖然點斜線常見於基於 Unix 的命令列操作中,但 Web 開發人員可能會在包含檔案或資源(例如映像、CSS 或 JavaScript 檔案)的路徑中看到它。它告訴瀏覽器請求相對於網頁目前目錄的資源。
兩個點後面跟著一個斜杠“../ ”代表父目錄,而不是當前目錄。這是一個相對路徑,告訴系統從目前目錄向上一級目錄。它通常用於存取比您目前所在的層次結構高一級的檔案或目錄。
當您執行位於系統路徑中某處的命令時,您不會使用點斜線。像“ls”、“grep”或“cd”這樣的系統命令不需要“./ ”,因為它們通常可以在路徑環境變數中已有的目錄中找到,因此 shell 知道在哪裡可以找到它們。
當您在互動式 shell 中工作時,使用點斜線是在目前目錄中執行程式的手動方法。在腳本中,您可以使用它來確保您呼叫的程式或腳本是從已知位置執行的,從而降低由於路徑問題而意外執行錯誤程式的風險。
僅使用不帶點斜線的檔案名稱依賴系統的路徑來尋找可執行檔。如果該檔案位於您的路徑中的目錄中,您可以直接呼叫它。點斜線明確告訴系統繞過路徑並在當前目錄中查找,如果當前目錄不在路徑中,則這一點至關重要。
點斜線通常用於執行腳本或二進位。但是,當您為在應用程式中開啟檔案等操作提供路徑時,它也可用於引用任何檔案類型。它表示提供的路徑從目前目錄開始,無論是用於執行、開啟或以其他方式存取檔案。
在圖形介面中,通常不使用點斜線。您可以透過點擊檔案或使用其他圖形工具來執行檔案。點斜線是一個命令列概念,大多數圖形介面都會在幕後為您處理路徑上下文。
您無法將腳本設定為始終使用點斜線固有地運行。每次您想從目前目錄中的命令列運行它時,您都需要使用點斜線。但是,如果您需要頻繁訪問,您可以建立一個別名或包含點斜線的 shell 函數,或添加指向路徑中目錄的符號連結。
點斜線通常不用於直接設定環境變數。環境變數設定為在不同目錄中通常絕對一致的路徑。但是,在使用設定環境變數的腳本時,您可以使用點斜線從目前目錄執行這些腳本。
環境變數可以在路徑中使用,但它們通常用於指定不隨當前目錄更改的絕對路徑。理論上,您可以在腳本中將環境變數與點斜線連接起來,但這將是非常規的,並且可能會導致混亂或錯誤。
本術語表僅供參考。它是理解常用術語和概念的有用資源。但是,如果您需要有關我們產品的特定支援或協助,我們鼓勵您造訪我們的專門 支援網站. 我們的支援團隊隨時準備好協助解決您可能遇到的任何問題或疑慮。