TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Desed: Demystify and debug your sed scripts

168 pointsby asicsp9 months ago

13 comments

leetrout9 months ago
Related, `sd` is a great utility worth the install which makes simple sed-type operations more obvious &#x2F; easier (for some value of easy).<p><a href="https:&#x2F;&#x2F;github.com&#x2F;chmln&#x2F;sd">https:&#x2F;&#x2F;github.com&#x2F;chmln&#x2F;sd</a>
评论 #41454916 未加载
评论 #41455015 未加载
评论 #41454321 未加载
qwertox9 months ago
&gt; Why sed??<p>&gt; Sed is the perfect programming language, especially for graph problems. It&#x27;s plain and simple and doesn&#x27;t clutter your screen with useless identifiers like if, for, while, or int. Furthermore since it doesn&#x27;t have things like numbers, it&#x27;s very simple to use.<p>&quot;useless identifiers like if, for, while, or int&quot;? Useless identifiers?
评论 #41454886 未加载
评论 #41456220 未加载
ok1234569 months ago
This is built into perl:<p>perl -MO=Deparse -w -naF: -le &#x27;print $F[2]&#x27;
trey-jones9 months ago
Once in HN comments I saw `sed` referred to as a one-way hashing function, and that&#x27;s always stuck with me - not just for sed, but for any type of operation that ends up being sort of a &quot;black box&quot;. Input becomes output reliably, but it&#x27;s hell to understand how. My big take away was: These types of operations are OK, when necessary, but it&#x27;s a good idea to take the time to write some comments&#x2F;documentation so the next person who looks at it (including self) has somewhere to start.<p>That said, debugging is definitely a thing, and tools like this are awesome!
sylware9 months ago
I am done with regular expressions languages and engines. Each time I wanted to do a not so trivial usage of it, I had to re-learn the language(s) and debug it, not to mention the editing operations on top of them (sed...).<p>This has been quite annoying. So now I code it in C or assembly fusing common-cases code templates and ready build scripts to have a comfortable dev loop.<p>In the end, I get roughly the same results and I don&#x27;t need those regular expressions languages and engines.<p>It is a clear win in that case.
mifydev9 months ago
Oh, I definitely need to run this one on <a href="https:&#x2F;&#x2F;github.com&#x2F;chebykinn&#x2F;sedmario">https:&#x2F;&#x2F;github.com&#x2F;chebykinn&#x2F;sedmario</a>
JoelJacobson9 months ago
I wish there was a similar tool for relational algebraic expressions, to make relational database research papers more accessible.
mlegendre9 months ago
Amusingly, in French, &quot;desed&quot; sounds like &quot;décéde&quot;, which means die &#x2F; decease. That&#x27;s quite a fitting name for a tool one would use in &quot;I need to debug a sed script&quot; situations!
评论 #41457459 未加载
Anthony-G8 months ago
I was happy to learn that<p>&gt; GNU sed actually provides pretty useful debugging interface, try it yourself with `--debug` flag.
russfink9 months ago
No Debian (Ubuntu, Mint and friends) version?
hiAndrewQuinn9 months ago
I feel we&#x27;re witnessing a resurgence of interest in &#x27;nix default programs such as `sed` and `awk` in part because LLMs make it so much easier to get started in them, and because they really do exist <i>everywhere</i> you might look. (The fact they were designed to be performant in bygone decades and are super-performant now as a result is also nice!)<p>There is just something incredibly freeing about knowing you can sit down at a freshly-reinstalled box and do productive work without having to install a single thing on the box itself first.<p>EDIT: <a href="https:&#x2F;&#x2F;hiandrewquinn.github.io&#x2F;til-site&#x2F;posts&#x2F;what-programming-languages-come-out-of-the-box-on-debian-12&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hiandrewquinn.github.io&#x2F;til-site&#x2F;posts&#x2F;what-programm...</a> might be of interest if you want to know what you can work with right out of the box on Debian 12. Other distros might differ.
评论 #41454178 未加载
评论 #41454069 未加载
评论 #41453959 未加载
评论 #41455023 未加载
评论 #41453985 未加载
tqwhite9 months ago
IMPOSSIBLE!!! God made sed as a test for humans to prove their humility. It is intrinsically mysterious.
评论 #41459154 未加载
aidos9 months ago
sed, awk, grep and friends are just so effective at trawling through text.<p>I dump about 150GB of Postgres logs a day (I know, it&#x27;s over the top but I only keep a few days worth and there have been several occasions where I was saved by being able to pick through them).<p>At that size you even need to give up on grepping, really. I&#x27;ve written a tiny bash script that uses the fact that log lines start with a timestamp and `dd` for immediate extraction. This allows me to quickly binary search for the location I&#x27;m interested in.<p>Then I can `dd` to dump the region of the file I want. After that I have an little awk script that lets me collapse the sql lines (since they break across multiple lines) to make grepping really easy.<p>All in all it&#x27;s a handful of old school script that makes an almost impossible task easy.
评论 #41456126 未加载