Skip to content

Instantly share code, notes, and snippets.

@jason-riddle
Last active October 21, 2019 01:24
Show Gist options
  • Select an option

  • Save jason-riddle/e7a38d024091cc417308a2ace94db2bb to your computer and use it in GitHub Desktop.

Select an option

Save jason-riddle/e7a38d024091cc417308a2ace94db2bb to your computer and use it in GitHub Desktop.
Examples using find #snippet #complete
# More on Performance
# Ref: https://unix.stackexchange.com/questions/41740/find-exec-vs-find-xargs-which-one-to-choose
# Ref: https://www.everythingcli.org/find-exec-vs-find-xargs
# Find all files, including hidden, that match the name "config"
find . -type f -name config
# Find all files that contain the word "git" in the filename
find . -type f -iname '*git*'
# Same as above but exclude hidden folders and files
find . -not -path '*/\.*' -type f -iname '*git*'
# Find all files except those in '.git/' and '.terraform/'
find . -type f \
-not \( -path '*/.git/*' -o -path '*/.terraform/*' \)
# Find all files then echo with 'name:'
find . -type f \
| xargs -I{} echo 'name: {}'
# Find all files then run ls on the file
find ./shells -type f \
| -exec ls '{}' \+
# Same as above but use xargs which offers parallism, albeit with less portability. `xargs -P` adds parallism, but is not in the POSIX standard.
find ./shells -type f \
| xargs -I{} ls '{}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment