linux中 shell脚本地址参数

#!/bin/bash
#
[ $# lt 2 ] && echo "At least two files" && exit 1 --(错误退出) 
 $#是脚本参数语句 判断输入的参数如果小于2个则继续后面的命令 

file1_lines=$(grep "^$" $1 | wc -l)
file2_lines=$(grep "^$" $2 | wc -l)
 
匹配输入对应地址变量$1\$2的文件(在命令行中手动输入)的空白行 ^$ ,并且通过wc -l命令统计行数

echo "Total blank lines: $[$file1_lines+$file2_lines]"
统计两个输入文件的空白行总数 

 

posted @ 2018-05-28 11:29  bin_WSJ  阅读(172)  评论(0编辑  收藏  举报