Latest News : 亮瞎双眼的那些年!

shell移除没有内容的目录

乱弹 admin 403 views 0 comments
#!/bin/bash
 
# 定义起始目录,这里使用当前目录
startdir="."
 
# 使用find命令查找所有空目录
find "$startdir" -type d -empty -exec rmdir {} +
 
# 或者使用find命令配合-depth选项来确保父目录在子目录被删除后也为空
find "$startdir" -depth -type d -empty -exec rmdir {} +

 

Please indicate: 无趣的人生也产生有意思的事件 » shell移除没有内容的目录

Hi, you must log in to comment !