Say I have a shell script at ~/script.sh
:
TEST="$1 $2"
echo $TEST
And I run it with bash ~/script.sh "he " "he"
,
The output of the command will be he he
, but I expected it to be he he
because the first argument, which is quote, has a space as the last character of the quote.
echo "$TEST"
. – Kamil Maciorowski Apr 01 '21 at 11:30printf '%s\n' "$TEST"
asecho
may modify the contents of the string under some circumstances (like interpreting\n
as "newline"). – Kusalananda Apr 01 '21 at 11:52