Created
August 21, 2019 17:08
-
-
Save mrsarm/905500e74a0b2d0b1aa0041abf4c2834 to your computer and use it in GitHub Desktop.
find-samples.sh: examples of how to use the `find` command, and combine it with others commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find in the current folder (recursively) all the files with .xml extension. | |
find . -name '*.xml' | |
# Find all the __pycache__ files (or folders) and execute | |
# for each result the command `rm -r` with the filename as a first argument | |
find . -name "__pycache__" -print0 | xargs -0 rm -r | |
# Find into the /tmp folder files that the path matchs a regex expression | |
find /tmp -regextype posix-egrep -regex ".*\.(le|c)ss$" | |
# Find all the JSON files with the word "Username" on it, and then print the 5 surrounding lines for each found | |
find . -name '*.json' -exec egrep -Hn -C 5 "Username" {} \; | egrep -C 5 "Username" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment