我是 powershell 的新手,遇到了一個奇怪的錯誤:
\Downloads> dlurl = "https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi"
dlurl : The term 'dlurl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
dlurl = "https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi"
~~~~~
CategoryInfo : ObjectNotFound: (dlurl:String) [], CommandNotFoundException
一些建議?
uj5u.com熱心網友回復:
與 POSIX 兼容的 shell(例如 Bash)不同,PowerShell$在創建(分配給)變數時也需要使用前綴符號,而不僅僅是在獲取它們的值時。
所以:
$dlurl = "https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi"
注意:考慮'...'對逐字內容使用字串。
沒有$,dlurl被解釋為命令名稱,后面的所有內容都作為它的引數,這解釋了您看到的錯誤(您的系統上不存在該名稱的命令)。
也可以看看:
概念about_Variables幫助主題。
about_Parsing,解釋了PowerShell的兩種基本決議模式,引數模式(類shell)和運算式模式(類編程語言);它是決定進入何種模式的陳述句的第一個標記。可以在此答案中找到更系統的概述。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/383531.html
上一篇:洗掉變數中的檔案-bash
