Linux Bash script to remove files older than 3 days
来源:互联网 发布:mastercam线割编程 编辑:程序博客网 时间:2024/05/16 15:39
Can someone help me with a bash script to remove files older than 3 days in directory /u1/database/prod/arch?
Hi,
You could use a 'simple' one-liner for this:
find /u1/database/prod/arch -type f -mtime +3 -exec rm {} \;
Or as bash script:
Code:
#!/bin/bash
find /u1/database/prod/arch -type f -mtime +3 -exec rm {} \; The only 2 commands used are find and rm.
Find looks for files (-type f), this to exclude directories, that are older then 3 days (-mtime +3). All it finds is given to rm (-exec rm {} \; ).
You could also place the rm statement outside of find, which is supposed to be faster:
find /u1/database/prod/arch -type f -mtime +3 | xargs rm
All the three examples do their searching recursively.
man find for details.
Hope this helps.
- Linux Bash script to remove files older than 3 days
- Batch script to delete file older than N days
- Delete Files Older Than x Days on Linux
- Delete log files longer than 45 days
- error: newly created file is older than distributed files!
- configure: error: newly created file is older than distributed files!
- How to Manually Update Bash to Patch Shellshock Bug on Older Fedora-Based Linux Systems
- Linux Bash Script
- linux bash script
- Linux Bash Script
- freebsd安装发生错误:newly created file is older than distributed files!
- configure: error: newly created file is older than distributed files! 错误处理
- 编译错误:configure: error: newly created file is older than distributed files!
- linux bash script简明手册
- linux bash script简明手册
- Warning: Variable 'a' cannot be saved to a MAT-file whose version is older than 7.3.
- Warning: Variable 'a' cannot be saved to a MAT-file whose version is older than 7.3.
- Matlab 之 cannot be saved to a MAT-file whose version is older than 7.3
- 巧妙查询 SQLite中存储文件大小的SQL语句
- Oracle Weblogic nodemanager STOP script Bash and Python
- 面向对象--多继承&派生类对象内存布局分析&各基类指针所指向的位置分析
- Javascript中的回调函数和匿名函数的回调
- 子父类中的变量,函数,构造函数的特点以及子类的实例化过程
- Linux Bash script to remove files older than 3 days
- Custom ShowDialog() method for WPF
- RMI 问题
- linux的五种进程
- JavaScript 中的所有事物都是对象:字符串、数值、数组、函数...
- JavaScript中对象属性的添加和删除
- 计算汉明权重的好方法~
- 下一个字典序列(next permutation)
- java ToolTipText() 设置换行 字体 和 显示时间