Closed julianhatwell closed 4 years ago
Thanks for this. I think you're using a different version of echo
. Both the BSD version of echo
and the Bash builtin work without the -e option. I won't change this, because I have started working on the second edition, but I will pay attention to this when I get to Chapter 5. Thanks again.
The opening code example is given as:
$ echo 'foo\nbar\nfoo' | sort | uniq -c | sort -nr
2 foo
1 bar
$ echo 'foo\nbar\nfoo' | sort | uniq -c | sort -nr |
but should be:
$ echo -e 'foo\nbar\nfoo' | sort | uniq -c | sort -nr
2 foo
1 bar
$ echo -e 'foo\nbar\nfoo' | sort | uniq -c | sort -nr |
-e switch is required for interpolating escaped \n. Without it, the example doesn't work.