#!/bin/bash
#files 代表文件 *代表当前目录 expr是linux下的计算程序 ‘pwd’显示当前目录
counter=0
for files in *
do
counter=`expr $counter + 1`
done
echo "There are $counter files in `pwd` we need to process"
本文介绍了一个简单的Bash脚本,该脚本用于统计当前目录下所有以.doc结尾的文件数量,并输出这些文件的数量及所在目录。通过使用基本的Bash命令如for循环、expr进行数学运算和pwd获取当前工作目录,展示了如何实现这一功能。
#!/bin/bash
#files 代表文件 *代表当前目录 expr是linux下的计算程序 ‘pwd’显示当前目录
counter=0
for files in *
do
counter=`expr $counter + 1`
done
echo "There are $counter files in `pwd` we need to process"
156
2699

被折叠的 条评论
为什么被折叠?