The difference between $* and $@ [duplicate]

Unquoted, there is no difference — they’re expanded to all the arguments and they’re split accordingly. The difference comes when quoting. "$@" expands to properly quoted arguments and "$*" makes all arguments into a single argument. Take this for example:

#!/bin/bash

function print_args_at {
    printf "%s\n" "$@"
}

function print_args_star {
    printf "%s\n" "$*"
}

print_args_at "one" "two three" "four"
print_args_star "one" "two three" "four"

Then:

$ ./printf.sh 

one
two three
four

one two three four

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)