[英]How to copy/paste multi-line command line command into Command Prompt?
我正在嘗試將一些長的、多行的命令行命令復制/粘貼到 Windows 10 命令提示符中。
Linux 為此使用“\\”字符,因此例如在 Linux 中,您可以將以下內容從網站或文本文件復制/粘貼到終端窗口中(我假設這里使用圖形桌面環境):
python retrain.py \
--bottleneck_dir="/tf_files" \
--how_many_training_steps=500 \
--model_dir="/tf_files" \
--output_graph="/tf_files/retrained_graph.pb" \
--output_labels="/tf_files/retrained_labels.txt" \
--image_dir="/tf_files/flower_photos"
然后按回車,命令將運行。 這在網站或您保存的文本文件中看起來更加清晰。
問題是,我似乎無法為此計算出 Windows 等效項。 我意識到 ^ 字符在這種情況下等效於 Linux \\ 字符,但它似乎不適用於復制/粘貼。 例如,如果制作一個文本文件“dummy1.txt”,則復制/粘貼以下內容:
copy dummy1.txt ^
dummy2.txt
(注意第一行的 ^ 字符兩邊有一個空格)
我明白了:
對於這個兩行示例,這無關緊要,但是對於更復雜的命令(例如上面的 python 腳本),將所有需要復制/粘貼的文檔中的所有內容放在一行中會嚴重犧牲可讀性。 有沒有辦法讓它在 Windows 上工作? 如果這很重要,我目前正在使用 Windows 10。
我認為你需要像這樣對它進行 powershellafy:
$retrain = @{
bottleneck_dir = “/tf_files”
how_many_training_steps = “500"
model_dir= "/tf_files"
output_graph = "/tf_files/retrained_graph.pb"
output_labels = "/tf_files/retrained_labels.txt"
image_dir = "/tf_files/flower_photos"
}
#imaginary equivalent script
retrain.ps1 $retrain
如果您只是想將行分成多行,則轉義字符是反勾號 `
get-longcommand -name "long command" `
-date "today" `
-other-info "other stuff"
最后,請理解“Foreach”循環。 有很多種,這里是一個簡單的
$copy_list = @(get-childitem "C:\Path\to\files")
$new_dest = "C:\New\File\Destination"
foreach ($file in $copy_list) {
#This is for troubleshooting, outputs which file it is running
$file
copy-item -Path $file -Destination $new_dest
}
可能有類似 $file.fullname 之類的東西來傳輸路徑。 如果您使用 Powershell ISE,並使用調試例程,請在循環中的 '$file' 后立即暫停,您可以看到詳細信息。
享受!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.