4 ms·
> Am I holding it wrong? Yup. The six lines are meant to be put in a script file, then invoked with the number of results to print as the first arg, where ${1}
by s_kilk 9y ago
> Am I holding it wrong?
Yup. The six lines are meant to be put in a script file, then invoked with the number of results to print as the first arg, where ${1} will work correctly.
If you just paste it into the shell you get whatever ${1} is set to in your shell session.
- keithpeter 9y agoAll is now clear, thanks to both parent posts keith@lavazzared:~$ cat bash.txt | ./wordc.sh 10 4200 the 1822 is 1251 to 1221 a 1147 of 869 if 804 and 570 in 567 shell 562 command
- lesserknowndan 9y agoThis comment thread suggests that Knuth's approach is better, i.e., the shell script version doesn't really explain why, what, or how it is doing what it is doing. It could have been improved by being written in a literate style that explains how each UNIX command line tool is being used and why; and would have executed in exactly the same way.