0
I'm trying to get information about the types of all the files in a given directory tree. Running file
in the current directory works well enough, but it doesn't traverse into sub-directories, and there doesn't seem to an option to make it do so, which seems odd for a UNIX tool.
How exactly do I execute the file
command recursively, so that it lists the file types of all the files in a given directory and its subdirectories?
I suspected that, I was kinda just hoping there was an option to
file
that I was glossing over. It seems odd to create a tool advanced enough that it can uncompress archives to search but yet not provide a single option for recursive operation, and it's not what I've come to expect of UNIX-like tools. – Hashim – 2019-10-09T22:09:38.607Also, is piping to file superior to using
-exec
? – Hashim – 2019-10-09T22:27:53.127Yes, very. This version calls file once, exec calls it for every line, or every N lines. The forks and execs add up massively on a large operation. – davolfman – 2019-10-10T16:22:56.220
Also, the old Unix philosophy is "A set of small sharp tools". Combining tools to perform a job is part of that, so tools are built to be combined. For example putting human-output on stderr so the useful output piped form stdout is easier to work with by the next tool in line. More recent GNU and Linux stuff may not follow that exactly. – davolfman – 2019-10-10T16:26:20.933