Friday, December 04, 2009

Find all non-binary files in a directory

You've got to love that there are so many different ways to accomplish this. Here's one:


find . -type f | xargs file | grep -v ELF


1. Recursively finds all files in current directory
2. Pipes to file, which displays information about each file type
3. Pipes to grep, which checks to see that ELF is NOT in result text

file is a handy command. On Linux, binary files with show something like the following.


dvenable@dvenable:~/src$ file bin.exe
bin: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped

No comments: