top | item 41454709

(no title)

wolletd | 1 year ago

> try explaining how to use sed to a fresh graduate who's never seen it

Well, for starters, you just `s/<regex>/<replacement>/` and try to use that in your everyday work. Just forget about the syntax. It's a search-and-replace tool.

That's the only way I used sed for years. I've learned more since then, but it's still the command I use the most. And that's also what `sd` focuses on.

Also, if you want to replace newlines, just use `tr`, to hook onto the examples of sd. It may seem annoying to use a different tool, but there are two major advantages: 1. you're learning about the existence, capabilities and limitations of more tools 2. both `sed` and `tr` are probably available in your next shitty embedded busybox-driven device, while `sd` probably is not

As you said, the value comes from being around for a long time and, probably more importantly, still being present on nearly any Unix-like system.

discuss

order

No comments yet.