Operating System - HP-UX
1752806 Members
6686 Online
108789 Solutions
New Discussion

finding the ascii and binary files

 
SOLVED
Go to solution
T G Manikandan
Honored Contributor

finding the ascii and binary files

Is there a better way to find the ascii and binary files from a specified file list.

I am using

$find ./ -type f -exec file {} \;|egrep -i 'ascii|text'

1 REPLY 1
H.Merijn Brand (procura
Honored Contributor
Solution

Re: finding the ascii and binary files

If you don't have to deal with thousands and thousands of files, use xargs

Also remember that your command sequence will also show non-(ascii|text) files

lt09:/tmp 124 > cc -o textascii newer.c
lt09:/tmp 125 > file textascii
textascii: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
lt09:/tmp 126 >

So a little bit safer and faster:

# find . -type f | xargs file | grep -i -w -e ascii -e text

The perl way would be something like

# perl -MFile::Find -le'find(sub{-T$_&&print$File::Find::name},".")'

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn