Referring to other Q/As on SO, I added the following to my .bashrc:
function findandreplace {
find . -type f -name "$1" -not -path "*/.git/*" -print0 | xargs -0 sed -i 's/$2/$3/g'
}
Oddly, it doesn't do anything. When I change it to:
function findandreplace {
echo "find . -type f -name \"$1\" -not -path \"*/.git/*\" -print0 | xargs -0 sed -i 's/$2/$3/g'"
}
I get
$ findandreplace "*.cpp" "A.cpp" "B.cpp"
find . -type f -name "*.cpp" -not -path "*/.git/*" -print0 | xargs -0 sed -i 's/A.cpp/B.cpp/g'
as expected. Copy-pasting that command then performs the expected operation.
What's wrong with my initial function?