The file command describes the contents of all files that are passed as an argument. This way you can determine file contents without actually looking at file contents yourself.

$ file -b /bin/uncompress
POSIX shell script, ASCII text executable
$ file -b /bin/umount
setuid ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, …

In the above examples we have used the option -b to avoid that the file command prepends filenames to the output.

Assignment

Give a Unix command that generates an overview to stdout of all executable regular files below the /bin directory (including all of its underlying subdirectories). The overview must indicate how many of those files have the same description generated by the file command. If the description generated by the file command contains commas, only the part before the first comma must be retained. The descriptions in the overview must be listed according to decreasing number of occurrences and then lexicographically1 on the description itself.

Example

The result look like this:

     53 ELF 64-bit LSB executable
     22 POSIX shell script
     19 ELF 64-bit LSB shared object
      4 setuid ELF 64-bit LSB executable
      1 setuid ELF 64-bit LSB shared object