'FINDSTR in Command Prompt
I am trying to generate a file with all of the rows from an input file containing a certain string using the FINDSTR commanand in cmd.exe. My command below does not produce any results, whereas the FIND command (also below) shows that there are 182,688 rows containing the string I'm looking for...
FIND command:
FIND /c "searchstring" c:\Users\karl\Desktop\Report.csv
gives the following:
---------- C:\USERS\KARL\DESKTOP\REPORT.CSV: 182688
FINDSTR command:
findstr /i /c:"searchstring" c:\Users\karl\Desktop\Report.csv > results.out
gives me a blank file called results.out.
What am I missing?
Solution 1:[1]
Try this one. the /n gives a line number:
findstr /i /n "\<searchstring\>" c:\Users\karl\Desktop\Report.csv
Solution 2:[2]
Find some string inside all text files in current directory example:
cls & for %i in (*.txt) do find /i "search text" < "%i" && (echo : %i & echo -)
What you are missing is the redirector; if your last search file fails search, your code deletes all content of the result file. Replace with append redirector, eg, to store results of search in a file:
for %i in (*.txt) do (find /i "giff" < "%i" && (echo : %i & echo -)) >> results.txt
Tested in Win 10
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mmv_sat |
| Solution 2 |
