4 ms·
A Unix novice came to Master Foo and said: “I am confused. Is it not the Unix way that every program should concentrate on one thing and do it well?” Master Fo
by qsort 5y ago
A Unix novice came to Master Foo and said: “I am confused. Is it not the Unix way that every program should concentrate on one thing and do it well?”
Master Foo nodded.
The novice continued: “Isn't it also the Unix way that the wheel should not be reinvented?”
Master Foo nodded again.
“Why, then, are there several tools with similar capabilities in text processing: sed, awk and Perl? With which one can I best practice the Unix way?”
Master Foo asked the novice: “If you have a text file, what tool would you use to produce a copy with a few words in it replaced by strings of your choosing?”
The novice frowned and said: “Perl's regexps would be excessive for so simple a task. I do not know awk, and I have been writing sed scripts in the last few weeks. As I have some experience with sed, at the moment I would prefer it. But if the job only needed to be done once rather than repeatedly, a text editor would suffice.”
Master Foo nodded and replied: “When you are hungry, eat; when you are thirsty, drink; when you are tired, sleep.”
Upon hearing this, the novice was enlightened.
EDIT - source: http://www.catb.org/esr/writings/unix-koans/shell-tools.html http://www.catb.org/esr/writings/unix-koans/shell-tools.html
- virgilp 5y agoI am familiar with sleep, but I haven't used the other two UNIX commands yet. I've still got a long road to enlightenment.
- rbonvall 5y agoDon't worry. eat and drink are just old commands, but rewritten in Rust.
- rspk 5y agoThis is from Rootless Root: The Unix Koans of Master Foo - http://www.catb.org/esr/writings/unix-koans/shell-tools.html http://www.catb.org/esr/writings/unix-koans/shell-tools.html
- qsort 5y agoYes, thanks, should have mentioned that.
- dataflow 5y agoAre these fill-in-the-blank parables of some sort (or parodies perhaps)? I feel like I've seen every kind of story put in this format. Is there some historical context that makes these interesting?
- greenyoda 5y agoThey're in the style of old Zen parables. In fact, the line “When you are hungry, eat; when you are tired, sleep” is an old Zen saying.
- jhrmnn 5y agohttps://en.wikipedia.org/wiki/Koan https://en.wikipedia.org/wiki/Koan
- praptak 5y agoThis is the historical context: https://terebess.hu/zen/Mumon.pdf https://terebess.hu/zen/Mumon.pdf Why it is historically and culturally significant: https://en.wikipedia.org/wiki/The_Gateless_Barrier https://en.wikipedia.org/wiki/The_Gateless_Barrier
- jbverschoor 5y ago"Everything is a file" Unix is an OS for I/O streams / lines. That's what it's good at. That's what the tools are designed for.
- vbezhenar 5y agoAnd that's how they spectacularly fail when something does not fit into that paradigm. Like file name with `\n`. Apparently now you need `\0`-separated lines and all the tools need `-0` or `-z` switches, console does not print it well and all that card house breaks apart.
- jbverschoor 5y agoYup. It's a nice abstraction, but for many things an object-graph / object-stream makes more sense. The output / rendering can be a tree or a table.
- sebazzz 5y agoWhich is the reason I love PowerShell.
- deleted 5y ago[deleted]
- rjh29 5y agoMissing the point, but imagine learning perl, sed and awk (and requiring everyone else to know all three) when you could just use Perl to do everything. perl -pie 's/foo/bar/'