After years of experience I wouldn't use "file" for anything I needed
to work reliably.
If the test is really ELF or not ELF, how about detecting the ELF
header magic directly?
$ if [[ $(dd if="/bin/ls" status=none bs=4 count=1) == $'\x7fELF' ]];
then echo elf ; else echo not-elf; fi
elf
$ if [[ $(dd if="/etc/passwd" status=none bs=4 count=1) == $'\x7fELF'
]]; then echo elf ; else echo not-elf; fi
not-elf
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW