Fix breakage with symlinks or special files.

Fix `file` command usage and match regex, so that links are followed,
and "special" files (directories, device files, named pipes, sockets and
empty files) are not matched.