find

Search for files

Usage

      find DIRECTORY
    

List files in DIRECTORY recursively

Common Flags

-type TYPE File is of type TYPE, commonly f (file) or d (directory)-maxdepth DEPTH Descend at most DEPTH levels of directories-mindepth DEPTH Skip files not at least DEPTH directories deep-name PATTERN Only show filenames matching PATTERNEXPR1 -o EXPR2 EXPR1 or EXPR2-not EXPR not EXPR-exec COMMAND \; -exec COMMAND {} +

Examples

Count lines of code in project

      find src tests \( -name ".cpp" -o -name ".hpp" \) -exec wc -l {} +
    

Count the number of lines inside .cpp and .hpp files inside the src and test directories

Symlink dotfiles

      find .* -type f -not -path ".git/*" -exec cp -sv $PWD/{} $HOME/{} \;
    

For each hidden file create a symlink to the home directory