Skip to content

Instantly share code, notes, and snippets.

@simbalinux
Last active November 3, 2021 01:56
Show Gist options
  • Save simbalinux/99138d6a9dab4277fcbd0e28a6263829 to your computer and use it in GitHub Desktop.
Save simbalinux/99138d6a9dab4277fcbd0e28a6263829 to your computer and use it in GitHub Desktop.
using find command in linux
#!/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