Filter a text file into a new text file

Sorry for this fake question.

On Windows, I would like to be able to filter one .txt file into a new one. Filter all rows containing a specific row.

I know this can be very easy, but really appreciate a few pointers.

+6
source share
3 answers

Use the findstr command:

 findstr my-string filename > new-file 

findstr /? will give you a message on how to use findstr (including the /V switch if you want to filter the lines, rather than filter them.)

Or, if you are familiar with grep and want it to be on Windows, install Cygwin . :-)

+11
source

Powershell has some neat string comparison features . You can connect the output to a new file.

^^ There are some better links on how to use Powershell, but I cannot find them at this moment. If you are on the Powershell route, there are many examples on the Internet.

+1
source

There is a Logfilter log filtering utility (www.casstor.com) that can do this easily. You can define multiple filter lines, and also use regular expressions in your filters. I think this may be what you are looking for.

0
source

Source: https://habr.com/ru/post/902567/


All Articles