Multi-line, double quoted string triggers history expansion on subsequent single-quoted commands it gets piped to
问题 I am on GNU bash, version 4.3.11. Say I want to print unique lines on a file. I am using this approach, which works well on a file: $ cat a 9 10 9 11 $ awk '!seen[$0]++' a 9 10 11 However, if I get the input from stdin, using double quotes in a multi-line and piping to awk, it fails: $ echo "9 > 10 > 9 > 11" | awk '!seen[$0]++' bash: !seen[$0]++': event not found That is, bash tries to expand the command seen , which of course does not know because it is a variable name. But it shouldn't