RAhul
RAhul

Reputation: 163

Delete a string from all files in a directory

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.

Upvotes: 2

Views: 1463

Answers (1)

glenn jackman
glenn jackman

Reputation: 247022

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.

Upvotes: 3

Related Questions