The -type operator takes 'f' or 'd' to only output regular files or directories. The following only finds regular files.
$ find -type f
The following only finds directory files.
$ find -type d
The -name operator takes a regular expression and uses that against the filename. The following finds files named "*.java"
$ find -name "*.java"
The ! operator negates operand to the right. The following is an example of finding files
not named *.txt
$ find . -type f ! -name "*.txt" -print
Using pipes and xargs, the grep command can works on each file found
by the find command. The following finds files named "*.java", pipes
that output to xargs, and then greps for the string "import org.gnu".
$ find . -type f -name "*.java" -print0 | xargs -0 grep "import org.gnu"
$ find . -type f -printf '%s %p\n' | sort -nr | head -n 15
find -type f -printf "%f %s %p\n"|sort
find . -type f -printf "%T@ %Tc %p\n" | sort -n
Resolve the issue that shows the following message while trying to use the -printf operator by installing fineutils:
find: -printf: unknown primary or operator
brew reinstall findutils
Once findutils is installed, the -printf is used with the gfind command.