坏气十足 发表于 2018-8-27 10:53:18

shell练习-对指定目录下的符合条件的文件执行操作

  编写个shell脚本将当前目录下大于10K的文件,然后删除
  #!/bin/bash
  #author: liqilong
  #date: 2016-08-26
  #Decs: find the file (if they more than 10K)and remove them .
  for Filename in `ls -l|awk '$5 > 10240 {print $9}'`
  do
  rm -rf $Filename
  done
  echo "OK!"

页: [1]
查看完整版本: shell练习-对指定目录下的符合条件的文件执行操作