问题
I use findstr to search and output my search to another txt file but need to omit the filename, can anyone help pls? Thanks in advance!
My current batch file :- findstr "TEST" *.dat > output.txt
and the result of output.txt with all the filename Doc*.dat(which I need to remove):-
Doc (1).dat:2014-04-15;TEST TECHNOLOGY LTD
Doc (10).dat:2014-04-29;TEST TECHNOLOGY LTD
Doc (11).dat:2014-04-30;TEST TECHNOLOGY LTD
Doc (12).dat:2014-05-02;TEST TECHNOLOGY LTD
Doc (13).dat:2014-05-05;TEST TECHNOLOGY LTD
Doc (14).dat:2014-05-06;TEST TECHNOLOGY LTD
Best Regards, W
回答1:
findstr
writes the filename, when you use wildcards.
Alternatives:
use another command, that doesn't write the filename in the same line as the content:
find "TEST" *.dat |find "TEST" >output.txt
or:
use findstr
without wildcards (use a for
loop to supply one filename at a time)
for %%i in (*.dat) do findstr "TEST" %%i >>output.txt
来源:https://stackoverflow.com/questions/23655237/how-to-remove-filename-in-findstr-output-file