cal.sh
sh cal.sh 20 + 10 implement a function such parameter passing (shell is not a strict programming language, this parameter is not defined, direct reference function, the shell performs direct write)
#!/bin/bash # cal() { case $2 in +) echo "`expr $1 + $3`" ;; -) echo "`expr $1 - $3`" ;; \*) echo "`expr $1 \* $3`" ;; /) echo "`expr $1 / $3`" ;; esac }