Extracting a file type recursively from a directory using find {linux}

FInd¬†–¬†search for files in a directory hierarchy.

Usage(general)

find <search directory> <search pattern> <action>

Example(finding all jpeg(s) in current dir)

find . -iname \*.jpeg -print0

Xargs – build and execute command lines from standard input

cp -v {} /dir/where/to/put/it

grep searches for PATTERNS in each FILE.

required command(to extract all the pictures) >

find . -name '*' -exec file {} \; | grep -o -P '^.+: \w+ image' | cut -d':' -f1 | xargs -I{} cp -v {} /dir/where/to/put/it