1. How to find items that have a certain pattern in their name

    While backing up my Mac Os today I found the need to mass copy some files and directories from my home folder. Most of them contained a certain pattern so this helped a lot.

    List of directories that start with “wo”:

    find . -maxdepth 1 -type d -regex “.*/wo.*”

    List of files that end with “rk”:

    find . -maxdepth 1 -type f -regex “.*/.*rk$”

    Copying to /destination/path/ all directories that contain “foo” in their name:

    find . -maxdepth 1 -type d -regex “.*/.*foo.*” -exec cp -r {} /destionation/path/ \;

    In the above command lose the -r after cp and replace -type d with -type f to perform the same action, but on files.