Thursday, April 23, 2015

Findstr regexp quick note:
As you may know regexp or regular expressions are there to ease our work
Using awk,sed is very common. But it can also be used to quickly search some patterns in windows native command findstr.
If you are not familiar with regexp it is like telling your computer you want to search some patterns instead of a literal search.
Literal search would be: dir file.txt : file.txt is the filename
Regexp search would be: dir *.txt : the asterisk is part of the regexp search, it is a very silly simple example but you understand the idea.

So for example you have a list of directories or shares.
And what you need is to find only the subfolders, at the 3rd level.
You can you use findstr in this way:
type shares-with-quotes.txt | findstr /r /c:"\\\\.*\\.*\\.*"