Searching by file name
As Chris mentioned in his answer you can use find
to do this but I find it much faster to search through the locate
database.
Assuming your distro provides this facility, most of the big ones do, Ubuntu, Fedora, CentOS, etc.
Example
$ locate --basename .mp4 .mkv .wmv .flv .webm .mov .avi | head -5
/home/saml/Desktop/sample_mpeg4.mp4
/home/saml/Downloads/Karrolls_Christmas/Karroll's Christmas (2004) part 1.mp4
/home/saml/Downloads/Karrolls_Christmas/Karroll's Christmas (2004) part 10.mp4
/home/saml/Downloads/Karrolls_Christmas/Karroll's Christmas (2004) part 2.mp4
/home/saml/Downloads/Karrolls_Christmas/Karroll's Christmas (2004) part 3.mp4
Searching by file type
To find the files by type you can use the command file
to get a list of info about a particular file's type.
Here's a rough list of these file types from my system, Fedora 19.
- .mp4: ISO Media, MPEG v4 system, version 1
- .mkv: EBML file, creator matroska
- .wmv: Microsoft ASF
- .flv: Macromedia Flash Video
- .webm: WebM
- .mov: ISO Media, Apple QuickTime movie
- .avi: AVI
You can use this command to find all the files in your /home/<user>
directory.
$ find /home/<user> -type f -exec file {} + | \
grep -E "MPEG v4|EBML|\
Microsoft ASF|Macromedia Flash Video|WebM|Apple QuickTime movie|AVI"
Alternatively you can use file
and search by mime-types that are categorized as "video".
-i, --mime
Causes the file command to output mime type strings rather than
the more traditional human readable ones. Thus it may say
‘text/plain; charset=us-ascii’ rather than “ASCII text”.
Adapting what we've done above to something like this:
$ find /home/<user> -type f -exec file -i {} + | grep video
You can use sed
to get just the filenames:
$ find /home/<user> -type f -exec file -i {} + |
sed -n '/video/s/:[^:]\+$//p'