[Gllug] find by mime type

Bruce Richardson itsbruce at uklinux.net
Tue Jun 29 14:06:56 UTC 2004


On Tue, Jun 29, 2004 at 02:30:11PM +0100, Neil wrote:
> People,
> I'm trying to find files of a particular mime type. I think I can 
> achieve this using pattern matching with the 'find' command - except I 
> can't figure out how to! Would someone be kind enough to offer a few 
> pointers?

Find doesn't do mime types.  Find's parameters check against simpler
properties like filename or the various properties (last modified,
permissions, owner) that are stored in a file's inode.  The "file"
utility, on the other hand, can examine a file and give a mime type if
you pass it the -i parameter.  However, file doesn't do recursive
searches, so you need to use file and find together.  Something like

	find /path/to/search | xargs file -i | grep text/html

replacing 'text/html' with whatever you're looking for.

-- 
Bruce

The ice-caps are melting, tra-la-la-la.  All the world is drowning,
tra-la-la-la-la.  -- Tiny Tim.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: Digital signature
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20040629/3b920d84/attachment.pgp>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list