Hjertnes.blog

Learning SED

May 26, 2019

Sed is this weird unix tool, it is basically a command line tool for doing text editor stuff as a command line command. It can work directly on files or by piping things into it and redirecting the output.

This is one of the things I should have taken the time to learn a million years ago. But I didn’t. So I spent some time learning it a few weekends ago.

Always use the -E option, it makes the regular expressions a little bit less What the fuck. Sed have become how I do large scale search and replace after the inital learning period. The big advantage to it over a text editor is that it scales much better. I used to and still use Visual Studio Code for this a lot of the time, because it’s inteface for it is awesome. But it fails beyond the point of being funny if you try to do use it on thousands of files.

Use -i if you want to do in place editing aka doing it on the actual files; and for christ sake, use git. The manual is the place to start.