Replace string in all files recursevely

447 Views Asked by At

I have a private project called A I now want to call B. I can easily move the content from A to B, but how do I rename all content A to be now B? Specifically

const A = 1;

I want to replace that with

const B = 1;

In a smart way, where I replace all occurrences of A with B recursively?

1

There are 1 best solutions below

2
VonC On BEST ANSWER

If you are sure about your expression to replace, you can try one of the solutions of "How to do a recursive find/replace of a string with awk or sed?"

Typically: a findfollowed with a -exec sed -i.

That would be enough to replace a fixed string by another.

Then add, commit and push back to your GitHub repo.

The OP davidkonrad confirms in the comments:

As a case sensitive search/replace within the directory:

sudo find ./ -type f -exec sed -i -e 's/A/B/g' {} \;