[beyes@localhost shift_dir]$ cat test-1.txt
1
2
3
4
[beyes@localhost shift_dir]$ cat test-2.txt
1
2
3
[beyes@localhost shift_dir]$ cat test-3.txt
7
8
9
#!/bin/bash
#opt2
usage() #参数输入不符要求提示
{
echo "usage:`basename $0` filenames"
}
totalline=0
if [ $# -lt 2 ]; then
usage #位置参数不能少于 2 个
exit
fi
while [ $# -ne 0 ]
do
line=`cat $1 | wc -l` #第一个位置参数对应文件的内容行数
echo "$1 : ${line}"
totalline=$[ $totalline+$line ] #累加每个文件内容行数的
shift #左移位置参数
done
echo "---------------------------------"
echo "total:${totalline}"
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |