Search This Blog

Friday, March 2, 2012

HowTo: search for files excluding binary files on Linux

search for files excluding binary files - The UNIX and Linux Forums

An old problem with CVS is that you need to identify the binary files as you add them in (cvs add -kb). Otherwise, the next version will do an ASCII merge, trash the previous version, and you won't know until you try to restore an old version. Mostly happens when moving between Linux and Windows. Thanks to zazzybob, this will find ASCII files really well, and save me a bunch of work.

find . -type f -print | xargs file | grep "ASCII\|HTML\|text\|XML" | cut -d: -f1

Finds all binary files (almost) but very close...With the CVS problem, 'cvs add' the known good ASCII files, and any that are missed won't be re-added...

find . -type f -print | xargs file | grep -v "ASCII\|HTML\|text\|XML" | cut -d: -f1

No comments:

Post a Comment