0

I have large textfile with this structure:

MTXT file Version 1
    file    001 good stuff
    file    002 sdfdsfsf
    file    003 cool stuff
    file    004 fjgfhjhgj
base64
    file    005 more cool stuff
    file    006 dgfdgfdgfcf
    file    007 dfgdgffdg
   -
009 fsf002dsdfds
010 dsfsfd003dsfs
011 sdf005sd001fs
001 IMPORTANT STUFF with numbers than can also contain 001, 002, 005 etc!
002 asfdasdsa
003 IMPORTANT STUFF with numbers than can also contain 001, 002, 005 etc!
004 vld2004sfsfd005sfds
005 IMPORTANT STUFF with numbers than can also contain 001, 002, 005 etc!

For further processing I want to get rid of all lines that do not start with 001, 003 and 005. However, the search criteria must incorporate the position of the 001, 003, 005 at the beginning of the line, as the datasets often contains similar numbers.

So the output I want is this:

001 IMPORTANT STUFF with numbers than can also contain 001, 002, 005 etc!
003 IMPORTANT STUFF with numbers than can also contain 001, 002, 005 etc!
005 IMPORTANT STUFF with numbers than can also contain 001, 002, 005 etc!

As I have to do this on various machines a simple Windows OS command would be best (e.g. like this Delete certain lines in a txt file via a batch file). But I could also life with a python script.

Community
  • 1
  • 1

1 Answers1

2

Use findstr /b to look for any of the specified space-separated numbers at the beginning of a line:

findstr /b "001 003 005" yourfile.txt
wOxxOm
  • 65,848
  • 11
  • 132
  • 136