I want to do this:
findstr /s /c:some-symbol *
or the grep equivalent
grep -R some-symbol *
but I need the utility to autodetect files encoded in UTF-16 (and friends) and search them appropriately. My files even have the byte-ordering mark FFEE in them so I'm not even looking for heroic autodetection.
Any suggestions?
I'm referring to Windows Vista and XP.
Thanks for the suggestions. I was referring to Windows Vista and XP.
I also discovered this workaround, using free Sysinternals strings.exe
:
C:\> strings -s -b dir_tree_to_search | grep regexp
Strings.exe
extracts all of the strings it finds (from binaries, but works fine with text files too) and prepends each result with a filename and colon, so take that into account in the regexp (or use cut or another step in the pipeline). The -s
makes it do a recursive extraction and -b
just suppresses the banner message.
Ultimately I'm still kind of surprised that the flagship searching utilities Gnu grep
and findstr
don't handle Unicode character encodings natively.