# simple sed question



## waiting_for_OSX (Sep 7, 2009)

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.


----------



## gamemaniac (Sep 11, 2009)

Your question have just left me confused a little. Perhaps I know the answer but not sure right now.


----------



## ElDiabloConCaca (Sep 11, 2009)

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.


----------



## gamemaniac (Sep 12, 2009)

Thanks ElDiabloConCaca that's what was not coming to my mind?


----------

