Chained FINDSTRs

Now that I learnt that FINDSTR is more flexible than I thought, a quick post on how to apply chained FINDSTR calls.

For instance, if you need to search all XPOs that have the words “holiday” and “GBR” (Brazilian localization tag). You could use the “/f” switch which accepts a file containing the files to look into. First example to make it clearer:

findstr /i /m /s "holiday" *.xpo > holiday_files.txt
findstr /i /m /f:holiday_files.txt "gbr"

Which will first create a file with the list of files with “holiday” (“/m” switch) and then look in the files from this list (“/f:file”) for the “GBR” occurrence.

A special case would be using the “/f:/” switch which accepts the file list from the console (stdin). So a more direct call would be:

findstr /i /m /s "holiday" *.xpo | findstr /i /m /f:/ "gbr"

Finally, use UniqueOcc to make it beautiful!

findstr /i /m /s "holiday" *.xpo | findstr /i /f:/ "gbr" | UniqueOcc

Of course this will not search “holiday” inside GBR tags. This is another task for a future post.

This entry was posted in Dynamics AX, English. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>