I'm trying to find a way to let the find command only find files, that could possibly have a shared library dependency (meaning they produce output when called with ldd).To find all dependencies of a group of files (binaries, text, office, etc.), I go through them with find . -type f and call ldd on all of them, then parse the output.I know that find has the -executable test option, but I'm not sure, if that covers all my bases.I know that ldd gives output similar to The Program isn't dynamically linked , but I would like to save myself the command, for files which cannot have shared libraries.
Which types of files can have a shared library dependency?
files;find;shared library
ldd dumps the dependencies of Elf files.  All Elf files start with the bytes \x7F 'E' 'L' 'F', which is probably the fastest way to test them.  However, I'm not aware of any option in find which reads the content of the file.  find mainly just looks at the metadata in the directory listing, like filename, mode bits, and so on.However, in order to run an Elf file it must have its Execute bit set.  If you do have an Elf file with no execute bit, it can't be executed, so you probably don't care about it.  So if you're looking for a quick way to speed up your search, checking for the execute bits should be safe.I recommend -perm /555 instead of -executeable, because the first checks for any execute bit, and the second checks whether the current user can execute it.But, in addition to dynamic languages like Python like jofel mentioned, many C programs will dynamically link against the PAM libraries (/lib/security/pam_*.so) and the libc nss libraries (/lib/libnss*.so).  If you're building a chroot or something, you need these.