0

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.

  • 2
    Does this answer your question? [Why does my shell script choke on whitespace or other special characters?](https://unix.stackexchange.com/questions/131766/why-does-my-shell-script-choke-on-whitespace-or-other-special-characters) In short: `echo "$TEST"`. – Kamil Maciorowski Apr 01 '21 at 11:30
  • Even better with `printf '%s\n' "$TEST"` as `echo` may modify the contents of the string under some circumstances (like interpreting `\n` as "newline"). – Kusalananda Apr 01 '21 at 11:52

0 Answers0