How To Search (And Replace) Quickly Across Directories

How To Search (And Replace) Quickly Across Directories

To find things quickly - use the silver searcher.

brew install the_silver_searcher

To find things:

ag 'the thing to find'

To see the count:

ag 'the thing to find' --count

To see the list of files only and search on a literal string:

ag 'the thing to find' -Q -l

To then replace the occurrences of the found use:

ag 'thething' -Q -l|xargs sed -i 's/thething/bar/g'