In the process of analyzing or writing code, you often need to search for strings in the file or compare the two files. Common commands in Linux are grep and diff. Windows files have good open-source tools, such as winmerge. Searching for strings in files is unclear whether there are good open-source tools. Recently, we found that Windows has a doscommand to meet your needs.
Findstr: Search for strings in the file.
/S searches for matched files in the current directory and all subdirectories.
/C: String uses the specified string as the text search string.
<B> examples </B>
01:
Findstr "computer help" myfile.txt
Output the line containing the computer or help string in myfile.txt to the DOS console.
02:
Findstr/s "computer help" *. txt
Similar to the preceding example, search for strings containing computer and help in the current directory and subdirectory TXT files.
03:
Findstr/S/C: "computer help" *. txt
Find the string containing "computer help" in the current directory and subdirectory TXT file.
FC: Compare the differences between two files or file Sets
<B> examples </B>
FC file1 file2
Doscommand findstr and FC