$ @ y $ * en scripts de shell

@ Sum @ sum La diferencia entre @ y *

#!/bin/bash

# $@ and $* 

my_fun (){
    
    

    echo "$#"

}



echo 'the number of parameter in "$@"   is'    $(my_fun  "$@")
echo 'the number of parameter in "$*"     is'     $(my_fun  "$*")

echo 'the number of parameter in $@      is'    $(my_fun  $@)
echo 'the number of parameter in $*        is'     $(my_fun  $*)
[lf@x201t ~]$ sh a.sh p1 "p2 p3" p4

the number of parameter in "$@" is 3  
the number of parameter in "$*" is 1

the number of parameter in $@ is 4
the number of parameter in $* is 4

¿Ves la diferencia? La clave $ @ es más confiable

Supongo que te gusta

Origin blog.csdn.net/qq_22648091/article/details/108544894
Recomendado
Clasificación