2

I am looking for a tool/command to delete string "http://" from all files within a directory. I am using the following command on my MacOS but am not able to accomplish the task.

grep -lr --exclude-dir=".git" -e "http://" . | xargs sed -i "" "s/"http:\/\/"//g"

I get the following error on command line:

sed: RE error: illegal byte sequence

Please help. Thanks in advance.

RAhul
  • 163
  • 1
  • 5
  • 15
  • 1
    Look at the related question on the right: http://stackoverflow.com/questions/19242275/sed-re-error-illegal-byte-sequence-on-mac-os-x – devnull Apr 08 '14 at 18:27
  • That seems to be solution for Linux. I am asking for solution in MacOS. Also, I am not sure if the command is totally correct. – RAhul Apr 08 '14 at 18:38
  • Did you try `find . -type f -exec sed -i "" 's|http://||g' {} \;` – devnull Apr 08 '14 at 18:40

1 Answers1

3

You have double quotes within a double quoted string. Try

grep ... | xargs sed -i "" 's@"http://"@@g'

Using different delimiters for s/// to avoid the leaning toothpick syndrome.

glenn jackman
  • 238,783
  • 38
  • 220
  • 352