4 ms·
What commands is Kernighan using in his spell checker example? makewords? lowercase? unique? mismatch? Were these really commands in AT&T unix? I kind of suspec
by smabie 6y ago
What commands is Kernighan using in his spell checker example? makewords? lowercase? unique? mismatch? Were these really commands in AT&T unix? I kind of suspect that they created some "unique" shell scripts for this video to make it easier to understand..
His full command is:
$ makewords sentence | lowercase | sort | unique | mismatch
- anthk 6y agomakewords -> tr ' ' '\n' unique -> uniq lowercase is easy, tr a-z A-Z mismatch -> loop and grep over the wordlist and check if the output on non-zero (no match), print that word. A trivial script. (while read line ; do if (grep -q "$line" /usr/share/dict/words) ; then ... )
- smabie 6y agoYeah, of course. But why is this video claiming they are Unix commands when they are not? Are these just little shell scripts designed for the camera?
- anthk 6y agoThey may be, or not. Long ago grep was composed of an ed script (g/re/p), and a spell checker was trivially done this way over grepping /usr/share/dict/words. The point is to show pipes to the public so they understand command chaining.
- LeoPanthera 6y agoMaybe the idea is that every shell script compromised of existing, simpler commands, is automatically itself a "command" in UNIX. Obvious and simple today, but not a common concept when this video was made.
- TomMarius 6y agoWasn't that the same in operating systems like MS-DOS and its predecessors, and on Apple computers as well?
- nineteen999 6y agoWell yeah I guess if you are thinking in terms of batch scripts, but DOS didn't exist until 1980, and UNIX had already been doing this within a multiuser, multitasking environment since at least 1972.
- TomMarius 6y agoOh, my bad, I confused the decade.
- deviantfero 6y agoKernighan is good at explaining things, so I'm guessing he wanted to make it as simple as posible, some of those just don't roll of your tongue as well as the aliased versions
- sergeykish 6y ago> existing UNIX programs (on your machine). They emphasize that users build their own vocabulary. And it is quite possible these command were shared inside AT&T.
- mork5zid 6y agoI don't think mismatch was grepping over the dictionary at all. That's too slow. The reason you sort the input text first is because it's reading the input text and the dictionary at the same time, making only a single pass through the dictionary...
- Wald76 6y agoI bet he just aliased commands for expository reasons: “uniq” aliased to “unique”, and “tr A-Z a-z” to “lowercase”.
- jedieaston 6y agoI just checked in an AT&T UNIX emulator, and it doesn't look like any of those commands exist. I think they made them for the video.
- teddyh 6y agoHe also uses “p” as an alias for “more” (or possibly “cat”).
- pmarin 6y agoThe program is still in Plan9. http://9p.io/magic/man2html/1/p http://9p.io/magic/man2html/1/p https://github.com/0intro/plan9/blob/master/sys/src/cmd/p.c https://github.com/0intro/plan9/blob/master/sys/src/cmd/p.c