在实际的linux系统管理中,你可能需要如下的操作: 
1,To get status of files after unzipping the zipped file
2,Alpha Numeric Validater
3,identification of the CATIA V4 Licenses require
4,Passing parameters to BTEQ
5,Find/Replace word in files inside zipfile
本文分享的这个shell脚本,可用于任何基于UNIX的系统上的目录中文件数的统计。
脚本很简单,也很实用,大家可以根据自己的需要自行修改。
代码:
 
复制代码 代码示例:
#!/bin/bash
# countf - count files in a directory (while listing)
#        - option to count only files matching suffix supplied by arg#2
#
#usage:  countf directory [suffix]
#
 if [ -d "$1" ]; then :
    else echo "ERROR, usage:  countf directory [suffix]"
    exit 1; fi
#
 rm -f a.txt
 x=0;y=0
 for i in $1/*
 do
    let x=x+1
    file $i | grep  "directory"  
    if [ $? -eq 0 ]
    then
    let x=x-1
    fi 
    f=${i##*/}
    g=${f%$2}
    if [ "$2" = "" -o "$g" != "$f" ]; then
       let y=y+1;
       echo "file# $x $y - $i " >> a.txt
    fi
    echo "file# $x $y - $i "
 done
 echo "$x total files in directory $1"
 if [ -n "$2" ]; then
    echo "$y files with matching suffix $2"; fi
 exit 0