Why does bash interpret “n” as new line character in interactive shells only and not when executing a shell script also?
Running in an interactive bash
shell:
$ echo "hellonworld"
hello
world
Running as a script using bash
:
$ echo 'echo "hello\nworld"' > hello_world.sh
$ bash hello_world.sh
hellonworld
Running as a script using sh
:
$ sh hello_world.sh
hello
world