If, like me, your minimalist unix doesn't include niceties like the file command, and backslashes in your grep expressions just don't cooperate, try this:
$ for file in `find . -type f` ; do
> dump $file | cut -c9-50 | egrep -m1 -q ' 0d| 0d'
> if [ $? -eq 0 ] ; then echo $file ; fi
> done
Modifications you may want to make to the above include:
- tweak the find command to locate only the files you want to scan
- change the dump command to od or whatever file dump utility you have
- confirm that the cut command includes both a leading and trailing space as well as just the hexadecimal character output from the dump utility
- limit the dump output to the first 1000 characters or so for efficiency
For example, something like this may work for you using od instead of dump:
od -t x2 -N 1000 $file | cut -c8- | egrep -m1 -q ' 0d| 0d|0d$'
dos2unix
with-ic
switch. For LF files you may search with unix2dos-ic
. It doesn't modify files. Only report. – gavenkoacat -v somefile.txt
; they show up as^M
– user5359531