Skip to content

Instantly share code, notes, and snippets.

@mondwan
Last active August 29, 2015 14:16
Show Gist options
  • Save mondwan/a78a2a9c643a3228a09e to your computer and use it in GitHub Desktop.
Save mondwan/a78a2a9c643a3228a09e to your computer and use it in GitHub Desktop.
Usage of Bash command find
# Find filename with gcc under folder /usr
find /usr -name gcc
# Find directory based on filename gcc under folder /usr
find /usr -type d -name gcc
# Find file which modified today under current directory
find -type f -mtime 0
# Find file which filesize is zero
find -type f -size 0
# Find filename with pattern a.* and echo them out
# `{}`
# a place holder that will be filled with all the file names that result from the find expression,
# and the preceding command will be run on each one individually.
find . -name 'a.*' -exec echo {} ';'
# For example,
#
# $> find . -name 'a.*' -exec echo {} ';'
# ./a.py
# ./a.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment