我想在 Windows PowerShell 中創建一個別名以從命令列洗掉多個檔案夾。
要洗掉我呼叫的多個專案:
Remove-Item '.\Documents\*\Bin\' ,'.\Documents\*\Inter\' -Force -Recurse
我試圖創建這樣的別名:
New-Alias -Name 'Clean-RCD' Remove-Item '.\Documents\*\Bin\' ,'.\Documents\*\Inter\' -Force -Recurse
輸出:
New-Alias: A positional parameter cannot be found that accepts argument 'System.Object[]'.
知道如何正確定義這個別名嗎?
uj5u.com熱心網友回復:
與 bash 不同,PowerShell 中的別名是嚴格的 1 對 1 命令名稱映射 - 不允許額外的引數引數。
你會想要創建一個function:
function Clean-RCD {
Remove-Item -Path '~\Documents\*\Bin', '~\Documents\*\Inter\' -Force -Recurse
}
使用~( 決議為您的主檔案夾) over.是有意的 - 這樣,如果您導航到不同的路徑,它仍然可以作業
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/352416.html
上一篇:如何遍歷物件的外殼陣列并使用jq從JSON檔案中洗掉它們?
下一篇:使用bash-c逐行決議
