hypotenuse.sh
来自「一本完整的描述Unix Shell 编程的工具书的所有范例」· Shell 代码 · 共 24 行
SH
24 行
#!/bin/bash# hypotenuse.sh: Returns the "hypotenuse" of a right triangle.# ( square root of sum of squares of the "legs")ARGS=2 # Script needs sides of triangle passed.E_BADARGS=65 # Wrong number of arguments.if [ $# -ne "$ARGS" ] # Test number of arguments to script.then echo "Usage: `basename $0` side_1 side_2" exit $E_BADARGSfiAWKSCRIPT=' { printf( "%3.7f\n", sqrt($1*$1 + $2*$2) ) } '# command(s) / parameters passed to awk# Now, pipe the parameters to awk.echo -n "Hypotenuse of $1 and $2 = "echo $1 $2 | awk "$AWKSCRIPT"exit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?