shell-for

来源:互联网 发布:java就业培训班 编辑:程序博客网 时间:2024/06/05 00:09
#!/bin/bash
#1-2-7
#变量count用于统计文件的数目
count=0
#变量files遍历一遍当前文件夹
for files in *
do 
#判断的files是否是文件,如果是将count变量的值加一再赋值给自己
#expr :表示数学运算
#`` 将其内的值给出
# = 两边都不能有空格
if [  -f "$files"    ];then
count=`expr $count + 1`   
fi
done
#输出结果
#"" 中不限制变量但会限制通配符
echo "There are $count file(s) in `pwd`"
	
				
		
原创粉丝点击