📄 col-totaler2.sh
字号:
#!/bin/bash# Another version of the "column totaler" script#+ that adds up a specified column (of numbers) in the target file.# This one uses indirect references.ARGS=2E_WRONGARGS=65if [ $# -ne "$ARGS" ] # Check for proper no. of command line args.then echo "Usage: `basename $0` filename column-number" exit $E_WRONGARGSfifilename=$1column_number=$2#===== Same as original script, up to this point =====## A multi-line awk script is invoked by awk ' ..... '# Begin awk script.# ------------------------------------------------awk "{ total += \$${column_number} # indirect reference}END { print total } " "$filename"# ------------------------------------------------# End awk script.# Indirect variable reference avoids the hassles#+ of referencing a shell variable within the embedded awk script.# Thanks, Stephane Chazelas.exit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -