doordx
doordx

Reputation: 15

SED command not replacing in actual file

I was migrating from Django 1.4 to 1.6 in which I have to replace all lines like {% URL test arg1...%} to {% URL "test" arg1...}

I used the following command:
find ./ -type f -exec sed 's/{% url \([^" >][^ >]*\)/{% url "\1"/g' *.html '{}' \;

It prints the desired output but do not make changes in the actual file? What is missing?

Upvotes: 1

Views: 846

Answers (1)

damgad
damgad

Reputation: 1446

From the manual of sed:

-i[SUFFIX], --in-place[=SUFFIX]
    edit files in place (makes backup if SUFFIX supplied)

So you should add -i option to modify the files 'in place'.

Whole command:

find ./ -type f -exec sed -i 's/{% url \([^" >][^ >]*\)/{% url "\1"/g' *.html '{}' \;

Upvotes: 1

Related Questions