What's the difference between $@ and $* in UNIX?

前端 未结 4 1453
青春惊慌失措
青春惊慌失措 2020-12-06 05:25

What\'s the difference between $@ and $* in UNIX? When echoed in a script, they both seem to produce the same output.

4条回答
  •  甜味超标
    2020-12-06 05:51

    It's safer to use "$@" instead of $*. When you use multiword strings as arguments to a shell script, it's only "$@" that interprets each quoted argument as a separate argument.

    As the output above suggests, if you use $*, the shell makes a wrong count of the arguments.

提交回复
热议问题