Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are no difference between <code>$*</code> and <code>$@</code>, but there is a difference between <code>"$@"</code> and <code>"$*"</code>. </p> <pre><code>$ cat 1.sh mkdir "$*" $ cat 2.sh mkdir "$@" $ sh 1.sh a "b c" d $ ls -l total 12 -rw-r--r-- 1 igor igor 11 mar 24 10:20 1.sh -rw-r--r-- 1 igor igor 11 mar 24 10:20 2.sh drwxr-xr-x 2 igor igor 4096 mar 24 10:21 a b c d </code></pre> <p>We gave three arguments to the script (<code>a</code>, <code>b c</code> and <code>d</code>) but in "$*" they all were merged into one argument <code>a b c d</code>.</p> <pre><code>$ sh 2.sh a "b c" d $ ls -l total 24 -rw-r--r-- 1 igor igor 11 mar 24 10:20 1.sh -rw-r--r-- 1 igor igor 11 mar 24 10:20 2.sh drwxr-xr-x 2 igor igor 4096 mar 24 10:21 a drwxr-xr-x 2 igor igor 4096 mar 24 10:21 a b c d drwxr-xr-x 2 igor igor 4096 mar 24 10:21 b c drwxr-xr-x 2 igor igor 4096 mar 24 10:21 d </code></pre> <p>You can see here, that <code>"$*"</code> means always one single argument, and <code>"$@"</code> contains as many arguments, as the script had. "$@" is a special token which means "wrap each individual argument in quotes". So <code>a "b c" d</code> becomes (or rather stays) <code>"a" "b c" "d"</code> instead of <code>"a b c d"</code> (<code>"$*"</code>) or <code>"a" "b" "c" "d"</code> (<code>$@</code> or <code>$*</code>).</p> <p>Also, I would recommend this beautiful reading on the theme:</p> <p><a href="http://tldp.org/LDP/abs/html/internalvariables.html#ARGLIST" rel="noreferrer">http://tldp.org/LDP/abs/html/internalvariables.html#ARGLIST</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload