Aquester 阅读(50) 评论(0)
下载:https://github.com/eyjian/libmooon/blob/master/shell/find_deleted_files.sh


  1. #!/bin/sh
  2. # 查找被删除但仍然占据磁盘的文件
  3. dirs=(`ls -l --time-style=long-iso /proc 2>/dev/null | awk '{ print $8 }' 2>/dev/null`)
  4. for ((i=0; i<${#dirs[@]}; ++i))
  5. do
  6. dir=${dirs[i]}
  7. if test -z "$dir"; then
  8. continue
  9. fi
  10. $(expr $dir + 0 > /dev/null 2>&1)
  11. if test $? -ne 0; then
  12. continue
  13. fi
  14. pid=$dir
  15. lsof -p $pid 2>/dev/null | grep "deleted" | grep -v "$0"
  16. done