Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# author: torpedoallen
# usage: grep and remove lines
# how-to: put the file into your PATH like /usr/local/bin and make it executable.
if [ -z "$2" ]; then git grep -zl "$1" | xargs -0 sed -i "/$1/d"; else git grep -zl "$1" -- $2 | xargs -0 sed -i "/$1/d"; fi
@torpedoallen
torpedoallen / git-sub
Last active February 24, 2022 15:09
git sub
#!/bin/bash
# author: torpedoallen
# usage: find and replace
# how-to: put the file into your PATH like /usr/local/bin and make it executable.
# reminders: the default sed command will no longer work fine with -i argument, please replace with gnu-sed
if [ -z "$3" ]; then git grep -zl "$1" | xargs -0 sed -i "s/$1/$2/g"; else git grep -zl "$1" -- $3 | xargs -0 sed -i "s/$1/$2/g"; fi