image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
LinkBack Thread Tools
  #1  
Old September 7th, 2009, 03:32 PM
Registered User
 
Join Date: Mar 2002
Posts: 103
Thanks: 1
Thanked 1 Time in 1 Post
waiting_for_OSX is on a distinguished road
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.
Reply With Quote
  #2  
Old September 11th, 2009, 02:12 AM
Registered User
 
Join Date: Sep 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
gamemaniac is on a distinguished road
Your question have just left me confused a little. Perhaps I know the answer but not sure right now.
Reply With Quote
  #3  
Old September 11th, 2009, 11:53 AM
ElDiabloConCaca's Avatar
Registered User
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 12,672
Thanks: 7
Thanked 388 Times in 370 Posts
ElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of light
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:

Code:
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.
__________________
Mac mini 2.0GHz 10.6.2 • 4GB • 320GB • Superdrive • 4 x 1TB USB 2.0 • LED Cinema Display
MacBook 2.0GHz Core 2 Duo - White 10.6.2 • 4GB • 250GB • CD-RW/DVD-ROM
iPhone 3G 8GB • iPod Touch 8GB • iPod Photo 60GB • iPod nano 1GB • AT&T U-Verse 18Mb/2Mb
http://www.jeffhoppe.com
Reply With Quote
  #4  
Old September 12th, 2009, 01:46 AM
Registered User
 
Join Date: Sep 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
gamemaniac is on a distinguished road
Thanks ElDiabloConCaca that's what was not coming to my mind?
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


All times are GMT -5. The time now is 03:38 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC1
Copyright 2000-2010 DigitalCrowd, Inc.