sum-product.sh
来自「Shall高级编程」· Shell 代码 · 共 29 行
SH
29 行
#!/bin/bash# sum-product.sh# A function may "return" more than one value.sum_and_product () # Calculates both sum and product of passed args.{ echo $(( $1 + $2 )) $(( $1 * $2 ))# Echoes to stdout each calculated value, separated by space.}echoecho "Enter first number "read firstechoecho "Enter second number "read secondechoretval=`sum_and_product $first $second` # Assigns output of function.sum=`echo "$retval" | awk '{print $1}'` # Assigns first field.product=`echo "$retval" | awk '{print $2}'` # Assigns second field.echo "$first + $second = $sum"echo "$first * $second = $product"echoexit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?