0

On OSX, I am trying to replace all occurrences of 2.7.10 in certain path in the following manner:

find . -type f  -path '*/*/dev/composer.json' \
-exec sed -i -e 's/2.7.10/dev-supported/7.x-2.7.10/g' {} \;`    

but the above command fails with error bad flag in substitute command: '.' so I tried escaping the dots as answers for similar questions suggest and the command looks like

find . -type f  -path '*/*/dev/composer.json' \
-exec sed -i -e 's/2\.7\.10/dev-supported/7\.x-2\.7\.10/g' {} \;

But that fails with bad flag in substitute command: '\' error.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
awm
  • 1,130
  • 3
  • 17
  • 37
  • 2
    The problem is the extra slashes. `sed` wants `s/.../.../g`. You're giving it `s/.../.../.../g`. Escape the slashes inside the pattern and replacement, or change the delimiter: `s#...#.../...#g`. Nothing to do with dots (except the fact that `7.x-2.7.10` is not a valid flag string). – Amadan Mar 16 '16 at 16:15
  • 2
    Possible duplicate of [Use slashes in sed replace](http://stackoverflow.com/questions/5864146/use-slashes-in-sed-replace) – Benjamin W. Mar 16 '16 at 17:26

0 Answers0