Home > Back-end >  The shell function parameters
The shell function parameters

Time:10-01

This is my
 
#!/bin/bash

The function getsum () {
The local sum=0
For n in $@
Do
((sum +=n))
The done
Return the $sum
}
# getsum $1 $2 $3 # calling function and pass parameters
# echo $?

Result=$(getsum $1 $2 $3) # calling function and pass parameters
Echo $result


$(getsum $1 $2 $3) should be have a problem, so I want to put the assignment and transfer in the way, how do I write this
  • Related