在批處理文件中使用下面的命令,我得到輸出,但還有一些回聲作爲回車。從WMIC輸出中刪除回車
wmic process where Caption='notepad.exe' get ProcessId,WorkingSetSize /Format:Texttable > output.txt
輸出:
ProcessId WorkingSetSize
4016 6356992
1548 6189056
如何擺脫在輸出這個回車?
EDIT1:
參考Foxdrive的工作答案在我的鏈接的問題我下面嘗試及其工作不錯,但在輸出那裏傳來一個額外的行:ECHO處於關閉狀態。不知道爲什麼?
@echo off
setlocal enabledelayedexpansion
(For /F "tokens=1,* delims==" %%A in (' "wmic process where Caption='notepad.exe' get ProcessId,WorkingSetSize /Format:Texttable" ') do (
set "line=%%A %%B"
set "line=!line:~0,-1!"
echo !line!
))>output.txt
output.txt中:
ProcessId WorkingSetSize
4768 6365184
5608 5500928
2888 6037504
1052 5472256
ECHO is off.
EDIT2:
ProcessId WorkingSetSize
4768 6365184
5608 5500928
2888 6037504
1052 5472256
我想在上面的格式輸出只和獲得使用輸出:
@echo off
setlocal enabledelayedexpansion
(For /F "delims=" %%A in ('"wmic process where Caption='notepad.exe' get ProcessId,WorkingSetSize /format:Texttable |findstr "[0-9P]" "') do (
set "line=%%A"
echo !line:~0,-1!
)) > output.txt
現在輸出中是否有任何尾隨CR? hexdump都可以命令沒有在我的系統工作.. :(..會感謝您的確認.. :)
可能重複的[編輯WMIC輸出格式](HTTP://計算器.com/questions/19462042/editing-wmic-output-format) – nephi12
@foxidrive請參閱** EDIT1 **問題.. :) – Sunny
是的..我需要這些值在第二個腳本中,但是當一個額外的CR來在輸出中,第二個腳本不起作用。 – Sunny