2 missing '
source | link

proof of concept, does not handle funny characters, assumes first extension is right.

file --mime-type -N *|sed \
   -e 's!^\(.*: \)\(.*\)$!echo \1;grep -e \2 /etc/mime.types!e' \
   -e 's!\n.*/[^     ]\+[    ]\+\([^ ]\+\).*! \1!' \
   -e 's!\n\(.*/[^     ]\)\+!\1!'

proof of concept, does not handle funny characters, assumes first extension is right.

file --mime-type -N *|sed \
   -e 's!^\(.*: \)\(.*\)$!echo \1;grep -e \2 /etc/mime.types!e' \
   -e 's!\n.*/[^     ]\+[    ]\+\([^ ]\+\).*! \1!' \
   -e 's!\n\(.*/[^     ]\)\+!\1!

proof of concept, does not handle funny characters, assumes first extension is right.

file --mime-type -N *|sed \
   -e 's!^\(.*: \)\(.*\)$!echo \1;grep -e \2 /etc/mime.types!e' \
   -e 's!\n.*/[^     ]\+[    ]\+\([^ ]\+\).*! \1!' \
   -e 's!\n\(.*/[^     ]\)\+!\1!'
1
source | link

proof of concept, does not handle funny characters, assumes first extension is right.

file --mime-type -N *|sed \
   -e 's!^\(.*: \)\(.*\)$!echo \1;grep -e \2 /etc/mime.types!e' \
   -e 's!\n.*/[^     ]\+[    ]\+\([^ ]\+\).*! \1!' \
   -e 's!\n\(.*/[^     ]\)\+!\1!