问题
Using batch, trying to get output of the following command:
wmic logicaldisk get caption,description,volumename
Thus, I'm simply doing the following:
wmic logicaldisk get caption,description,volumename >>"C:\out.log"
Unfortunately, this is the output I'm getting:
回答1:
The output from WMIC is unicode, your "spaces" are nulls from the two bytes unicode characters in file. Try with
wmic logicaldisk get caption,description,volumename | find /v "" >>"C:\out.log"
回答2:
wmic
has an output flag that you can use in place of redirect symbols that might work out better for you.
wmic /output:"C:\out.log" logicaldisk get caption,description,volumename
回答3:
I had no problem seeing the file, but when doing findstr
, I noticed it is not found. So I did the following and it will allow it to produce a regular ASCII text file.
Another solution is to type out the file and do it again
wmic logicaldisk get caption,description,volumename >>"C:\out.log"
type c:\out.log > c:\out1.log
findstr "your text" out1.log (instead of out.log)
来源:https://stackoverflow.com/questions/28672210/get-rid-of-spaces-and-tabs-in-wmic-output