#!/bin/bashif[ $# == 2 ];then
SPACE1=`grep'^$' $1 |wc -l`
SPACE2=`grep'^$' $2 |wc -l`echo Number of blank lines infile 1: $SPACE1echo Number of blank lines infile 2: $SPACE2echo Total number of blank lines:$[SPACE1+SPACE2]elseecho"参数个数错误,请指定两个文件!"fi
执行结果
[yinxd@centos7 ~]$ ./sumspace.sh /etc/yum.conf /etc/vimrc
Number of blank lines infile 1: 3
Number of blank lines infile 2: 7
Total number of blank lines:10