查找被删除但仍然占据磁盘的文件

2020-09-10 11:36:43 浏览数 (1)

下载:https://github.com/eyjian/libmooon/blob/master/shell/find_deleted_files.sh。

代码语言:javascript复制
 			#!/bin/sh 		
 			# 查找被删除但仍然占据磁盘的文件 		
 
 			dirs=(`ls -l --time-style=long-iso /proc 2>/dev/null | awk '{ print $8 }' 2>/dev/null`) 		
 			for ((i=0; i<${#dirs[@]};   i)) 		
 			do 		
 			dir=${dirs[i]} 		
 			if test -z "$dir"; then 		
 			continue 		
 			fi 		
 (expr dir   0 > /dev/null 2>&1) 		
 			if test $? -ne 0; then 		
 			continue 		
 			fi 		
 
 			pid=$dir 		
 			lsof -p pid 2>/dev/null | grep "deleted" | grep -v "
 			done 		

0 人点赞