Last active
November 3, 2021 01:56
-
-
Save simbalinux/99138d6a9dab4277fcbd0e28a6263829 to your computer and use it in GitHub Desktop.
using find command in linux
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
#!/usr/bin/env bash | |
# different ways to use the linux find command preferred choice typically. | |
find . -exec grep chrome {} + | |
#find will execute grep and will substitute {} with the filename(s) found. The difference between ; and + #is that with ; a single grep command for each file is executed whereas with + as many files as possible #are given as parameters to grep at once. | |
#If you use the \; ending construct grep is passed one file at a time, so it doesn't display the file name by default, only the matched lines. To get a file list instead add use grep -ls inside of the find construct. | |
find . -exec grep foo {} + will show you output like this ./dir/file.py:from foo import bar – s g Apr 17 '15 at 20:30 | |
find . -exec grep foo {} \; will show you output like this from foo import bar – s g Apr 17 '15 at 20:31 | |
find . -exec grep -l foo {} + will show you output like this ./dir/file.py – s g Apr 17 '15 at 20:32 | |
find . -exec grep -l foo {} \; will show you output like this ./dir/file.py – s g Apr 17 '15 at 20:33 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment