0

I have a huge log file (approx 10MB - 20000 rows) which contains the following sample data rows

081741.397 : Received:[8=FIX.4.4     9=68     35=0     34=157     49=CALUAT     52=20131216-08:17:41.239     56=FAUAT     10=232     ]
081749.587 : Send:[8=FIX.4.4     9=64     35=0     49=FAUAT     56=CALUAT     34=158     52=20131216-08:17:49     10=033     ]
081806.623 : Send:[8=FIX.4.4     9=583     35=AE     49=FAUAT     56=CALUAT     34=159     52=20131216-08:18:06     571=7CG8I6220131216     487=2     150=F]
081811.396 : Received:[8=FIX.4.4     9=68     35=0     34=158     49=CALUAT     52=20131216-08:18:11.239     56=FAUAT     10=231     ]
081815.920 : Send:[8=FIX.4.4     9=626     35=AE     49=FAUAT     56=CALUAT     34=160     52=20131216-08:18:15     571=9CG8IF220131216     487=2     150=F]
081824.173 : Send:[8=FIX.4.4     9=558     35=AE     49=FAUAT     56=CALUAT     34=161     52=20131216-08:18:24     571=11CG8I220131216     487=0     150=F]
081841.395 : Received:[8=FIX.4.4     9=68     35=0     34=159     49=CALUAT     52=20131216-08:18:41.239     56=FAUAT     10=235     ]
081858.539 : Send:[8=FIX.4.4     9=64     35=0     49=FAUAT     56=CALUAT     34=169     52=20131216-08:18:58     10=036     ]
081911.394 : Received:[8=FIX.4.4     9=68     35=0     34=160     49=CALUAT     52=20131216-08:19:11.239     56=FAUAT     10=225     ]
081919.303 : Send:[8=FIX.4.4     9=640     35=AE     49=FAUAT     56=CALUAT     34=170     52=20131216-08:19:19     571=27CG8J220131216     487=2     150=F]
081941.393 : Received:[8=FIX.4.4     9=68     35=0     34=161     49=CALUAT     52=20131216-08:19:41.239     56=FAUAT     10=229     ]  

I want to fetch only those rows which contains Send: and 35=AE. What sort of regex should I use in batch file to extract only the filtered rows and export them in a separate log file.

5
  • you want to remove the send or only want to see the send - I can do a regex for you when you clarify Commented Jan 15, 2014 at 12:34
  • Does 35=AE appear on any line without Send: on it? Commented Jan 15, 2014 at 12:42
  • @owen79 - Just want to filter out the send and export it to text file Commented Jan 15, 2014 at 13:07
  • @foxidrive - No it wont appear anywhere except for Send Commented Jan 15, 2014 at 13:07
  • okay, findstr /v /r 35=AE log.log > trimmed.log Commented Jan 15, 2014 at 13:19

6 Answers 6

1

This will find the string "Send:" followed by any squence of characters and the string "35=AE", reading the indicated input file and sending output to the indicated output file

findstr /r /c:"Send:.*35=AE" inputFile > outputFile

To get all the lines except the indicated, the add /v to the list of parameters of findstr to invert the match

EDIT: Removed < redirector dbenham's explanation (bug in FINDSTR)

Sign up to request clarification or add additional context in comments.

4 Comments

@PankajJaju, not really needed in this case. Just an habit. Instead of asking findstr to open the file to read, ask cmd to open the file and feed it into findstr.
Was asking because when I tried it, the records are directed to a new file correctly. However the command is not finishing.
@PankajJaju - There is a FINDSTR bug on XP and Windows 7 that causes it to hang if searching redirected input and the last line is misssing a new line character. Pass the name of the file as a parameter and let FINDSTR open it instead of using redirection. See What are the undocumented features and limitations of the Windows FINDSTR command? for a long list of FINDSTR "peculiarities"
@dbenham, i forget about it. Thanks
1

Your question isn't clear.

If you want to get those lines that contain BOTH of these strings, then

find "Send:" filename|find "35=AE" >a_new_file.txt

If you want to get those lines that EITHER of these strings, then

findstr /L "Send: 35=AE" filename >a_new_file.txt

In either case, add a /i switch to make the search case-insensitive if desired.

Comments

1

Try this

 findstr /R /I Send:\[.*35=AE.* search.log >> new.log

Comments

1

You could use the following to find the rows and send it to new file

FINDSTR Send.*35=AE a.txt > b.txt

Comments

1

This is another option, based upon the comments where 35=AE is a unique term.

find "35=AE" <"file.log" >"out.txt"

Comments

0

To only get the rows with Send and 35=AE use

^\d{6}.\d{3} : Send.*35=AE.*

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.