Bash lets you specify a redirected input before a command:
$ <lines sed 's/^/line: /g'
line: foo
line: bar
Bash also lets you redirect input to a compound command like a while
loop:
$ while read line; do echo "line: $line"; done <lines
line: foo
line: bar
However, when I try to specify a redirected input before a while
loop, I get a syntax error:
$ <lines while read line; do echo "line: $line"; done
bash: syntax error near unexpected token `do'
What's wrong with this? Is it not possible to specify a redirected input before a compound command in Bash? If so, why not?