Difference between $* and $@ in bash?

$* and $@, both these bash special variables expands to the positional parameters, starting from the first one.

These variables are same (expand positional parameters in same way) when using without double quotes. If these variables are using inside double quotes, it will expand positional parameters differently.

$* within double quotes ("$*") is equivalent to the list of positional parameters, separated by IFS variable.

Suppose IFS is ":" and hence expansion of "$*" will be like "$1:$2:$3:…"

And $@ within a pair of double quotes ("$@") is equivalent to the list of positional parameters separated by unquoted spaces, i.e., "$1" "$2".."$N". Or in other words, it is equivalent to the list of positional parameters where each parameters are double quoted.

For sake better understanding I wrote a script named star_and_at.sh and pushed to my public github repo

You can clone my bash github public repository directly using following command

Rename multiple files in an easy way.


Use the following bash script to rename multiple files in a directory.


# Date 14-02-2010
# Purpose : Renaming multiple files
lname=$#-1 # lname will hold total number of arguments minus one. The last argument is the new name argument.
for file in ${@:1:$lname}; do # the variable holds all all arguments except the last argument. The last argument is reserved for the new name.
mv $file $file.${@: -1}

Continue reading “Rename multiple files in an easy way.”