I frequently need to search and replace throughout my code base. I use sed:
find . -type f -exec sed -i 's/foo/bar/g' {} +
I would like to be able to just type
sr 's/foo/bar/g'
I tried to add this to my .bashrc:
function sr
{
find . -type f -exec sed -i '$1' {} +
}
But when I try to run sr 's/foo/bar/g'
I get
sed: -e expression #1, char 1: unknown command: `%'
How can I fix the above?