Copy all script arguments to another variable

前端 未结 1 386
你的背包
你的背包 2021-01-15 08:01

I need to copy all script arguments and pass them to another script. I have tried to do it like this:

args=$@    
printargs.sh $args
echo ------
printargs.sh         


        
相关标签:
1条回答
  • 2021-01-15 08:28

    $@ is like an array, so your temporary storage needs to be an array:

    args=( "$@" )      # quotes are needed there
    

    And then to use them:

    printargs.sh "${args[@]}"
    
    0 讨论(0)
提交回复
热议问题