爱是王道 发表于 2018-8-25 10:01:12

遍历文件夹并批量tar压缩的Shell脚本

#!/bin/bash  #Created on 2013-3-12
  #@author:victor
  #Batch compression all the files in a target directory.
  read -p "Pls input directory path:" target_dir
  #target_dir=/path
  for file in $(find $target_dir -type f)
  do
  if [ ${file##*.} = gz ]
  then
  echo "${file##*/} ......was tared pass!"
  else
  cd ${file%/*}
  tar zcvf ${file##*/}.tar.gz ${file##*/}
  echo "${file##*/} ......is tared ok!"
  rm -rf ${file##*/}
  fi
  done

页: [1]
查看完整版本: 遍历文件夹并批量tar压缩的Shell脚本