# Bash Patterns I Use Weekly ### 1. Find and replace a pattern in a codebase with capture groups **`git grep -l pattern | xargs gsed -ri 's|pat(tern)|\1s are birds|g'`** - `git grep -l`: make sure we're only looking for files in our codebase (`ag -l` is another good option) - `xargs`: allow running this with `gsed -i` - `gsed -i`: edit files (default mac `sed` is bad, so gnu-sed is essential) - `gsed -r`: use regular expression for the pattern to allow capture groups - `s|`: the first charact...