findstr command in windows

options illustrate
/l Processes search strings literally.
/r Processes search strings as regular expressions. This is the default setting.
/s Searches the current directory and all subdirectories.
/i Ignores the case of the characters when searching for the string.
/x Prints lines that match exactly.
/v Prints only lines that do not contain a match.
/n Prints the line number of each line that matches.
/m Prints only the file name if a file contains a match.
/o Prints character offset before each matching line.

some examples:

  • findstr /c:”hello world” hello.txt
    —————————-search string “hello world” in hello.txt file

  • findstr /n /i /r /c:”<.*>” movie.html > result.out
    —————————-find the pattern(regulation expression) in movie.html file and ouput the result to result.out file

  • findstr /n /i /s aba *.txt
    ——————————find string “aba” in all files in the current directory and its subdirectory

click here for details

猜你喜欢

转载自blog.csdn.net/qq_36336003/article/details/80293153