0

Why does this program return a?

$ cd /tmp
$ touch a
$ echo '[1a1]' | while read i; do echo $i; done
a

There is probably some globbing going on. But I don't understand it at all.

Karel
  • 1,438
  • 3
  • 13
  • 22
  • While [Why does my shell script choke on whitespace or other special characters?](//unix.stackexchange.com/q/131766) should answer your question, you may also want to read [Why is printf better than echo?](//unix.stackexchange.com/q/65803), [Understanding "IFS= read -r line"](//unix.stackexchange.com/q/209123) and [Why is using a shell loop to process text considered bad practice?](//unix.stackexchange.com/q/169716) – Stéphane Chazelas Nov 03 '21 at 19:00
  • (or IOW, in one line of code, you managed to combine quite a few basic (though common) mistakes) – Stéphane Chazelas Nov 03 '21 at 19:01

0 Answers0