help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] The difference between $* and "$*"?


From: Peng Yu
Subject: [Help-bash] The difference between $* and "$*"?
Date: Sat, 1 Feb 2014 10:03:51 -0600

Hi,

       *      Expands to the positional parameters, starting from  one.   When
              the  expansion occurs within double quotes, it expands to a sin-
              gle word with the value of each parameter separated by the first
              character of the IFS special variable.  That is, "$*" is equiva-
              lent to "$1c$2c...", where c is the first character of the value
              of  the IFS variable.  If IFS is unset, the parameters are sepa-
              rated by spaces.  If IFS is  null,  the  parameters  are  joined
              without intervening separators.

I'm trying to understand the different between $* and "$*". The
following shows that they behave differently when IFS is not the
default. But the above paragraph from the manual does not explain
this. Could anybody let me know if this is documented somewhere else
in the manual and how to understand the difference? Thanks.

~/linux/test/bash/man/variable/IFS/$*$ cat main.sh
#!/usr/bin/env bash

set -- a b c d
echo "$*"
OLDIFS="$IFS"
IFS=:
echo $*
echo "$*"
IFS="$OLDIFS"

~/linux/test/bash/man/variable/IFS/$*$ ./main.sh
a b c d
a b c d
a:b:c:d

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]