How To Preserve Quotes In Bash Arguments

If you want to preserve quoting to pass shell arguments to a called command, use the four characters “$@” (including the double quotes) instead of the two characters $*
![]() |
If you want to preserve quoting to pass shell arguments to a called command, use the four characters “$@” (including the double quotes) instead of the two characters $*
Solution: “Double Quote” your variables!
1 2 3 4 5 6 7 8 9 10 11 |
shell> myvar="abc def ghi" shell> echo $myvar abc def ghi shell> echo "$myvar" abc def ghi |
See Also: https://stackoverflow.com/questions/22101778/how-to-preserve-line-breaks-when-storing-command-output-to-a-variable