0

My FINDSTR command is very lengthy and I want to break it into multiple lines in my batch file. Here is the command:

type file.txt | findstr /v "string1" | findstr /v "string2" | findstr /v "string3" | findstr /v "string4" > newfile.txt

Is this possible? Ideally, I'd like each sequence (divided by the pipe characters) to be on its own line. Thanks in advance!

user1599051
  • 43
  • 1
  • 6

1 Answers1

0

Use ^ character:

type file.txt ^
    | findstr /v "string1" ^
    | findstr /v "string2" ^
    | findstr /v "string3" ^
    | findstr /v "string4" > newfile.txt

This is a normal way of splitting command into several lines in cmd.

See also: this answer.

Community
  • 1
  • 1
afenster
  • 3,007
  • 14
  • 21
  • When I run the batch file in CMD, this is what it says: `' ' is not recognized as an internal or external command, operable program or batch file.` – user1599051 Nov 08 '14 at 19:07
  • you are right, there should be no spaces before the command. I edited the answer, now splitting lines before `|` character. Checked that it works. – afenster Nov 08 '14 at 19:42