Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • If you want to create a single string from the positional parameters, use $* inside the quoted string. If you want to create multiple arguments for echo, use "$@" with no spaces around $@. Commented Jan 11, 2022 at 13:21
  • @they The " $@ " is also a single argument. I thought it closer to the OP's intention. Commented Jan 11, 2022 at 13:30
  • 1
    " $@ " is two arguments if there are two positional parameters (the same as " $1" "$2 "). You would recreate " $1 $2 " with " $* ", assuming the first character of $IFS is a space. Commented Jan 11, 2022 at 14:05
  • Strange, ksh tells me differently, concerning the " $@ ". Commented Jan 11, 2022 at 14:09
  • Which ksh is that? Both pdksh and ksh93 produces two lines from set -- "a b" "c d"; printf '"%s"\n' " $@ ". This user tagged their question with bash, and that shell behaves the same, as does dash. Commented Jan 11, 2022 at 14:13