shell示例

#!/bin/bash
DATE_FROM=`date -d "$1" +%Y%m%d`  
DATE_TO=`date -d "$2" +%Y%m%d`
FILE_NAME_START="icore-pnbsWII3830-"
FILE_NAME_TAIL=".tgz"
FILE_NAME_SIGN="acc"
while [[ $DATE_FROM < $DATE_TO  ]]  
do
    FILE_NAME="$FILE_NAME_START$DATE_FROM$FILE_NAME_TAIL"
    DATE_FROM=`date -d "+1 day $DATE_FROM" +%Y%m%d`  
    echo "================>>>$FILE_NAME"
    if [ -d "$FILE_NAME" ]
    then
      tar -xvf $FILE_NAME
      for file in ./*
      do  
          if test -f $file
          then
              echo "=============>>>$file"
              if [[ $dir_or_file == *$FILE_NAME_SIGN*  ]]
              then
                  sed '1,4d' $dir_or_file

              fi
          fi
      done
    else
        echo "file do not exist!!!"
    fi
done

你可能感兴趣的:(Linux,shell)