simple sed question


What is wrong with this bash command?

$ sed -i 's/localhost/myurl/g' myfile.php
sed: 1: "myfile.php": command a expects \ followed by text

Why doesn't this work to replace localhost with myurl in all php files?

$ sed -i 's/localhost/myurl/g' *.php
sed: 1: "myfile.php": command a expects \ followed by text

I'm using Snow Leopard.


U.S.D.A. Prime
The -i requires that you give an extension, even if it's a non-existent extension (for in-place editing).

Change the command to this:

sed -i '' 's/localhost/myurl/g' myfile.php
...and see if that works for you. Be aware that in-place editing will perform the edits on the files you specify without making backup copies, so it's dangerous in the sense that a malformed regex can permanently change the files you're working on without making backups of them.