Multiple choice technology operating systems

what is the significance of $@ in unix shell

  1. The total count of positional parameters.

  2. Name of the executed command

  3. same as $* except when enclosed in double quotes
  4. none of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Both $@ and $* represent all positional parameters, but they behave differently when enclosed in double quotes. "$@" expands each parameter as a separate word, preserving argument boundaries. "$*" expands all parameters as a single word, concatenating them with the first character of IFS. Without quotes, they behave identically.

AI explanation

In Unix/POSIX shells, $@ expands to all positional parameters and behaves the same as $* in most contexts — except when quoted: "$@" expands each positional parameter as a separate, individually-quoted word (preserving arguments containing spaces as distinct items), whereas "$" expands to a single word joined by the first character of IFS. So 'same as $ except when enclosed in double quotes' correctly captures this key distinction. The parameter count is held by $#, and the command name by $0 — not $@ — so the other options are wrong.