1

I have a text file that has fixed length data.

1234|test1|2015|Who are you
4567|test2||I'm a dumb guy
1234|test1|2015|We all know

I just need to remove line 2 by checking if position 12th value <> 2 (current year so will always be 2 for all rows until 2099 :)) then remove that line. In other words, just fetch rows which contains value 2 in position 12.

I tried searching and found this but I dont know how to re-write to look for a position = value.

type file.txt | findstr /v ERROR | findstr /v REFERENCE

Delete certain lines in a txt file via a batch file

Thanks so much..

Community
  • 1
  • 1

1 Answers1

3
findstr /r "...........2" "Data.txt"

See findstr /? for help. Also help.

Redirect output to a file.

findstr /r "...........2" "c:\folder\Data.txt" > "c:\folder\Output.txt"

See Trouble with renaming folders and sub folders using Batch for punctuation help.

Community
  • 1
  • 1