DEV Community

Sam Clark
Sam Clark

Posted on

Using sed To Find and Replace

Using sed to find and replace

When you need to find and replace a massive amount of modules(think of having to refactor a require to a privately scoped package at your company).

Luckily we're using a nix based system(unless it's windows...then whatever, enjoy windows). We can use sed which is basically going to run commands against a stream. find is basically going to pipe a stream directly into sed, and sed is going to run a simple find/replace scheme(just like we would if we were using vim).

fix foo and move it to point to a private repo:

find ./ -type f -exec sed -i "s/'foo/'@my-org\/foo/g" {} \;

Top comments (1)

Collapse
 
letsfindcourse profile image
letsfindcourse

This tutorial means that this is a brief introductory guide to SED that will help give beginners a solid foundation about concrete tasks.
letsfindcourse.com/tutorials/sed-t...