簡體   English   中英

將文件路徑參數傳遞給具有tr -d unix命令的cmd腳本時出錯

[英]Error while passing file path arguments to cmd script that has a tr -d unix command

在Windows環境中,我試圖將輸入和輸出文件路徑傳遞給cmd腳本,如下所示:

rem trim CTRL-Z char
tr -d '\032' < %1 > %2

該腳本的功能是修剪test1.txt中的字符並將內容放入test2.txt中

這就是我要這樣做的方式:

C:\Users\a\Desktop>script.cmd test1.txt test2.txt

這是我得到的輸出:

rem trim CTRL-Z char

tr -d '\032'  0<test1.txt 1>test2.txt
The system cannot find the file specified.

腳本基本上應該運行命令

tr -d '\032' < test1.txt > test2.txt

您能指出我在這里做錯了嗎? 那些0和1在大於和小於符號之前來自輸出?

提前致謝!

額外的問題:我寧願在同一個文件中進行修整,但就您所知,您無法使用CTRL-Z char上的“ tr”命令和“ sed -i”扼流圈進行就地處理,因此它不可用。 有任何已知的解決方法嗎?

該命令在Windows上對我來說效果很好。 嘗試在命令上運行以下序列以查看問題所在。

tr --help
tr -d '\032' test1.txt

0和1僅表示標准輸入和標准輸出

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM