Skip to content

Instantly share code, notes, and snippets.

@luckman212
Created December 23, 2021 18:25
Show Gist options
  • Save luckman212/ab07a0846c3bfedf077c1cf9930f4610 to your computer and use it in GitHub Desktop.
Save luckman212/ab07a0846c3bfedf077c1cf9930f4610 to your computer and use it in GitHub Desktop.
rgr: quick in-place search and replace using ripgrep + gsed
#!/usr/bin/env bash
case $1 in
-h|--help|'') echo "usage: ${0##*/} <old> <new>"; exit;;
esac
export old="\b$1\b"
export new=$2
rg --files-with-matches -0 "${old}" |
xargs -0 -I % gsed -E -i "s/${old}/${new}/g" -- %
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment