200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 查找空目录Linux 查找空文件夹

查找空目录Linux 查找空文件夹

时间:2020-11-17 14:53:54

相关推荐

查找空目录Linux 查找空文件夹

find . -name "*" -type f -size 0c | xargs -n 1 rm -f

就是删除1k大小的文件。(但注意不要用 -size 1k,这个得到的是占用空间1k,不是文件大小1k的)。用这个还可以删除指定大小的文件,只要修改对应的 -size 参数就行,例如:

find . -name "*" -type f -size 1024c | xargs -n 1 rm -f

find查找空文件夹

read -p 'please input dir name: ' path

find ${var_path:=/tmp} -type d -empty

查询所有/root/下的空文件夹

find /root -type d -empty

# cat empty_dir.sh

#!/bin/bash

##############################################################

# File Name: empty_dir.sh

# Version: V1.0

# Author: frs

# Organization:

# Created Time : -09-18 11:48:17

# Description:

##############################################################

var_path=$1

read -p 'please input yes|y|Y:' a

if [ $a == 'yes' -o $a == 'y' -o $a == 'Y' ]

then

for n in `ls -A ${var_path:=$PWD}`

do

file_num=`ls -A $n|wc -w`

if [ $file_num -eq 0 ]

then

rm -rf $n

fi

done

else

exit 1

fi

赞赏

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。