Re:A proof that Unix utility sed is Turing complete
by kccqzy on Thursday February 14, 2019 @11:59PM
(#19168557)
sed really is a powerful utility. I once wrote a tool in sed that strips HTML tags leaving just plain text as a fun exercise. Naturally it can't handle complicated cases but for many simple use cases it works. The code, though, is basically unreadable.
[ Parent
| on HN ]
Re:A proof that Unix utility sed is Turing complete
by saagarjha on Friday February 15, 2019 @03:31AM
(#19169380)
Given that sed is Turing complete, I'm sure if you tried harder you would have come up with a general solution ;)
Re:A proof that Unix utility sed is Turing complete
by mannykannot on Friday February 15, 2019 @09:28AM
(#19171138)
Absolutely. One approach would be to take this TM implementation and program it to parse HTML.
Re:A proof that Unix utility sed is Turing complete
by airstrike on Friday February 15, 2019 @12:02AM
(#19168569)
Any chance you could share that? Wouldn't mind giving it a whirl in this one side project I just started...
Re:A proof that Unix utility sed is Turing complete
by mirimir on Friday February 15, 2019 @08:43AM
(#19170821)
Isn't it more or less a cliche that using sed etc for stripping HTML tags is unreliable and potentially hazardous?
I've tried it. I could get it to apparently "work". But then I'd get some input that hosed it. Now I just use "w3m -dump". I mean, it's a browser.
Re:A proof that Unix utility sed is Turing complete
by noxToken on Friday February 15, 2019 @09:36AM
(#19171198)
There's the classic Stack Overflow answer[0] about matching HTML tags. If you have a small subset of HTML, it can work out pretty well.
[0]: https://stackoverflow.com/questions/1732348/regex-match-open...
Re:A proof that Unix utility sed is Turing complete
by mirimir on Friday February 15, 2019 @10:21AM
(#19171565)
Thanks. That's what I was thinking of. Classic "this parrot is dead" riff.
Re:A proof that Unix utility sed is Turing complete
by mannykannot on Friday February 15, 2019 @09:34AM
(#19171187)
The unreliability follows from it being "basically unreadable", which leads to it probably not doing what you intend. Whether it is hazardous depends on what you use it for.
Re:A proof that Unix utility sed is Turing complete
by james_s_tayler on Friday February 15, 2019 @01:12AM
(#19168838)
I used to write web scrapers with curl/grep/sed back in the day. Fun times.