1

I've been searching for this answer for three hours now and I still can't get anything to work. When I run things like this:

 sed -i 's/http\:\/\/www\.domain\.org\//\//g checkout_*.php

It drops me into another command line (sorry, I'm very new to sed).

I just want to cd to a dir, grep the dir to see if the string is there then run a replace so I can change my paths from absolute to relative.

Lynn
  • 559
  • 1
  • 6
  • 22

2 Answers2

7

You need to close your '. You can also make your command cleaner by using a different sed delimiter to / so that you don't have to escape all those forward slashes in your URL. For example, you can use !, as shown below:

sed -i 's!http://www\.domain\.org/!/!g' checkout_*.php
dogbane
  • 266,786
  • 75
  • 396
  • 414
  • The sed command is slightly different for mac. You need to specify a backup extension immediately following the -i paramaeter, eg. '.original' as noted here: http://stackoverflow.com/a/4247319/4158458 – brianfit May 31 '16 at 08:55
3

You just appear to be missing the closing '

sed -i 's/http\:\/\/www\.domain\.org\//\//g' checkout_*.php

Should do what you want ok. But I'd warn you against doing the -i switch without first doing a dry run.

ocodo
  • 29,401
  • 18
  • 105
  • 117
  • Yeah, you both were right. Sorry I didn't catch it before posting. thanks very much! – Lynn Mar 04 '11 at 22:54