Passing argument containing space in shell script

前端 未结 1 1751
青春惊慌失措
青春惊慌失措 2020-12-05 02:17

I need my script to be able to accept arguments with space characters. If, for example, I have a script as follows:

for SOME_VAR in $@
do
    echo \"$SOME_VA         


        
相关标签:
1条回答
  • 2020-12-05 02:58

    You must wrap the $@ in quotes, too: "$@"

    This tells the shell to ignore spaces in the arguments; it doesn't turn all arguments into a very long string.

    0 讨论(0)
提交回复
热议问题