So, I had to rename a server today. I could go through all the config files that reference the name by hand and change it. I could use grep to find them all easily and then change them by hand. Or I could use grep and sed wrapped in a bash one-liner and have it all done for me. Like so:
for i in `grep -lir oldname *`; do sed s/oldname/newname/ $i > $i.new; mv $i.new $i;done
It’s things like this that make working with Linux such a joy.