Get rid of spaces and tabs in wmic output

匆匆过客 提交于 2020-01-02 07:19:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!