find考点

 

1, 查找目录下以 txt后缀的文件进行重命名

find /opt/temp/ -name "*.txt" -exec sh -c 'mv "$0" "${0%.txt}.bak"' {} \; 
 
2, 查找目录下大于多少M的文件,然后进行移动?
 
find /var/log/  -size +5M -exec mv {} /opt/temp \;
 
3,查找7天以前修改过的文件并删除
 
find . -type f -mtime +7 -print
 
find . -mtime +7 -exec rm -f {} \;
posted @ 2024-04-19 13:17  lavida2000  阅读(16)  评论(0)    收藏  举报