Linux如何查找某个时间点后生成的空文件
今天遇到一个特殊需求,需要找到某天(例如2017-04-13)以及这之后生成的空文件。那么这个要怎么处理呢?这个当然是用find命令来解决。如下所示,
-mtime -5 表示查找距现在 5*24H 内修改过的文件
-type f -empty 表示空文件
由于需要以显示修改时间等文件信息,所以使用-exec ls -lt {}\; 具体命令如下所示:
$ find ./ -mtime -5 -type f -empty -exec ls -lt {} \; | more
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 15 21:30 ./PO/KK_WIS/in/POGETWISI09L3302.txt
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 15 23:40 ./PO/KK_WIS/log/POGETWISI09H3302.16643223.out
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 16 03:24 ./PO/KK_WIS/log/POGETWISI13R3705.16646635.out
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 15 23:43 ./PO/KK_WIS/log/POGETWISI09D3302.16643223.log
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 16 03:24 ./PO/KK_WIS/log/POGETWISI13R3705.16646635.log
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 15 03:25 ./PO/KK_WIS/log/POGETWISI13R3704.16643862.log
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 15 23:41 ./PO/KK_WIS/log/POGETWISI09L3302.16643223.out
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 15 23:40 ./PO/KK_WIS/log/POGETWISI09H3302.16643223.log
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 15 23:42 ./PO/KK_WIS/log/POGETWISI09S3302.16643223.out
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 15 23:41 ./PO/KK_WIS/log/POGETWISI09L3302.16643223.log
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 15 23:42 ./PO/KK_WIS/log/POGETWISI09S3302.16643223.log
............................................................
如果我们需要按修改时间做一个排序,那么可以使用下面命令:
$ find ./ -mtime -5 -type f -empty -exec ls -lt {} \; | sort -n -k6 |more
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 13 22:00 ./PO/CC_B2B/log/20170413.download.CICN.lst
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 13 22:00 ./PO/CC_B2B/log/20170413.download.FFI-EEL.lst
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 13 22:00 ./PO/CC_B2B/log/20170413.download.FFI-GET.lst
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 13 22:00 ./PO/CC_B2B/log/20170413.download.HSOCN-EEL.lst
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 13 22:00 ./PO/CC_B2B/log/20170413.download.HSOCN-GET.lst
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 13 23:01 ./PO/CC_B2B/arch/SOEELB2BI16N3473.16631117.txt
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 13 23:05 ./AP/CC_B2B/arch/APEELB2BLABI01H2919.16631124.txt
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 13 23:30 ./AP/CC_B2B/arch/APEELB2BI01H3660.16631214.txt
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 14 22:00 ./PO/CC_B2B/log/20170414.download.CICN.lst
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 14 22:00 ./PO/CC_B2B/log/20170414.download.FFI-EEL.lst
-rw-r--r--. 1 oaintprd oaintprd 0 Apr 14 22:00 ./PO/CC_B2B/log/20170414.download.FFI-GET.lst
............................................................
Linux如何查找某个时间点后生成的空文件的更多相关文章
- Linux查找某个时间点后生成的文件(转)
需要找到某天(例如2017-04-13)以及这之后生成的空文件.那么这个要怎么处理呢?这个当然是用find命令来解决.如下所示, -mtime -5表示查找距现在5*24H内修改过的文件 -type ...
- Linux如何查找处理文件名后包含空格的文件
Linux如何查找处理文件名后包含空格的文件 当Linux下文件名中出现空格这类特殊情况话,如何查找或确认那些文件名后有空格呢? 又怎么批量替换处理掉这些空格呢? 方法1: 输入文件名后使用Tab ...
- linux下php增加curl扩展,生成curl.so文件
进入php源代码目录 cd /php5.6.9/ext/curl 执行生成so文件编译模式 /usr/local/php/bin/phpize 编译curl扩展 ./configure --with- ...
- linux中ping带时间及打印内容到文件
ping命令就不多说了,-i是时间间隔,-c是ping的次数 这种是每隔30秒ping一次,并在后面显示时间: ping 192.168.30.123 -i 30 | awk '{ print $0& ...
- linux中find批量删除空文件及空文件夹
linux下批量删除空文件(大小等于0的文件)的方法 代码如下 复制代码 find . -name "*" -type f -size 0c | xargs -n 1 rm -f ...
- Linux如何查找文件的创建时间
Linux的文件能否找到文件的创建时间取决于文件系统类型,在ext4之前的早期文件系统中(ext.ext2.ext3),文件的元数据不会记录文件的创建时间,它只会记录访问时间.修改时间.更改时间(状态 ...
- Linux上查找
locate 用法:locate filename locate是Linux系统中的一个查找(定位)文件命令,和find命令等找寻文件的工作原理类似,但locate是通过生成一个文件和文件夹的索引数据 ...
- Linux下查找文件:which、whereis、locate、find 命令的区别
我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索.which 查看可执行文件的位置,通过环境变量查whereis 查看文件的位置,通过数据库查,每 ...
- linux下查找某个文件位置的方法
一.通过文件名查找法: 举例说明,假设你忘记了httpd.conf这个文件在系统的哪个目录 下,甚至在系统的某个地方也不知道,则这是可以使用如下命令: find / -name httpd.conf ...
随机推荐
- [Swift]LeetCode684. 冗余连接 | Redundant Connection
In this problem, a tree is an undirected graph that is connected and has no cycles. The given input ...
- [Swift]LeetCode1007. 行相等的最少多米诺旋转 | Minimum Domino Rotations For Equal Row
In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domi ...
- NumPy 学习笔记(三)
NumPy 数组操作: 1.修改数组形状 a.numpy.reshape(arr, newshape, order='C') 在不改变数据的条件下修改形状 b.numpy.ndarray.flat 是 ...
- django启动server报错Error: That port is already in use.
这种一般是端口错误,一般是要把端口关掉,这里提供了两种方法. 方法一:直接命令: sudo lsof -t -i tcp:8000 | xargs kill -9 方法二:脚本:名字manage.py ...
- C# listview展示表格格式
有时候我们需要展示表格格式的数据,首先想到的是用datagridview控件,比如更改datagridview某一行的数据,这样操作起来就比较麻烦,而listview属于轻量级,刷新和更改相对来说效率 ...
- scala的break和continue
scala 是没有 continue 的,但是包含 break,可以用 break 构造出 continue 的效果 这里用到了库: import scala.util.control.Breaks. ...
- linux安装字体方法
1.查看系统中文字体 #fc-list :lang=zh 2.如果提示commont not fount 说明为安装fontconfig 3.安装fontconfig #yum -y install ...
- asp.net core 系列 20 EF基于数据模型创建数据库
一.概述 本章使用 Entity Framework Core 构建执行基本数据访问的 ASP.NET Core MVC 应用程序.使用迁移(migrations)基于数据模型创建数据库,是一种cod ...
- Python爬虫入门教程 31-100 36氪(36kr)数据抓取 scrapy
1. 36氪(36kr)数据----写在前面 今天抓取一个新闻媒体,36kr的文章内容,也是为后面的数据分析做相应的准备的,预计在12月底,爬虫大概写到50篇案例的时刻,将会迎来一个新的内容,系统的数 ...
- Chapter 4 Invitations——17
"Then why —"He shrugged. "I was hoping you were just letting him down easy." “这为 ...