Hi
Just sharing my old notes on this topic.
Found these solutions on stack overflow years ago.
It's not as fancy as Rich's script, but it shows a slightly different route.
busybox find . -type f -exec head -c 4 {} \; -exec echo " {}" \; | awk '/^.ELF/{print $2}'
busybox find . -type f -exec head -c 4 {} \; -exec echo {} \; | awk '/^.ELF/{print substr($0,5)}'
busybox find . -type f -exec busybox head -c4 {} ';' -print | busybox awk '/^\x7fELF/{print(substr($0,5))}'
busybox find . -type f -exec busybox hexdump -n 4 -e '4/1 "%X"' {} ';' -exec echo {} ';' | busybox awk '/^7F454C46/{print substr($0,9)}'
findELF() {
# files in ELF format
busybox find "$1" -type f \
-exec busybox head -c4 {} ';' \
-print | busybox awk '/^\x7fELF/{print(substr($0,5))}'
}
findShebang() {
# files starts with '#!'
busybox find "$1" -type f \
-exec busybox head -c2 {} ';' \
-print | busybox awk '/^\x23\x21$/{print substr($0,3)}'
}