Bash version:
debian@debian:~$ bash --version |grep release
GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)
Variable expansion in echo:
debian@debian:~$ a=apple
debian@debian:~$ echo '"'$a'
'
"apple
debian@debian:~$
I type '"'$a'
and newline
and '
,echo parse it as three parts '"'
,$a
,'newline'
,so it is "
,apple
,\n
.What i analyse is the same as the output.Now remove the echo
to see what happens:
Variable expansion in terminal:
debian@debian:~$ '"'$a'
> '
bash: $'"apple\n': command not found
Why terminal parse it as $'"apple\n'
?