0

Why does:

[ "a" != "$(printf "\na")" ] && echo true || echo false

print true while:

[ "a" != "$(printf "\n")a" ] && echo true || echo false

print false?

glarry
  • 914
  • 1
  • 7
  • 16

1 Answers1

1

I think it is because $(...). That substitution automatically remove ending newline character. That's a good default behaviour.

Bach Lien
  • 229