バッチファイルで以下のコマンドを使用すると、出力が得られますが、キャリッジリターンとしていくつかのエコーが伴います。
wmic process where Caption='notepad.exe' get ProcessId,WorkingSetSize /Format:Texttable > output.txt
出力:
ProcessId WorkingSetSize
4016 6356992
1548 6189056
出力でこのキャリッジリターンを取り除く方法は?
EDIT1:
以下で試したリンクされた質問でFoxdriveの有効な回答を参照すると、うまく機能しますが、出力に余分な行が表示されます: ECHO is off. なぜかわからない?
@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 コマンドが機能しません..:(..ご確認いただければ幸いです..:)