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]LeetCode689. 三个无重叠子数组的最大和 | Maximum Sum of 3 Non-Overlapping Subarrays
In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. E ...
- Linux 工程向 Windows 平台迁移的一些小小 tips
Linux 工程向 Windows 平台迁移的一些小小 tips VS2013 C++11 Visual Studio 2013 没有做到对 C++11 所有的支持,其中存在的一个特性就是 In-cl ...
- 【译】编写支持SSR的通用组件指南
原文来自:https://blog.lichter.io/posts/the-guide-to-write-universal-ssr-ready-vue-compon?utm_campaign=Vu ...
- [Abp 源码分析]九、事件总线
0.简介 事件总线就是订阅/发布模式的一种实现,本质上事件总线的存在是为了降低耦合而存在的. 从上图可以看到事件由发布者发布到事件总线处理器当中,然后经由事件总线处理器调用订阅者的处理方法,而发布者和 ...
- 【Storm篇】--Storm从初始到分布式搭建
一.前述 Storm是一个流式处理框架,相比较于SparkStreaming是一个微批处理框架,hadoop是一个批处理框架. 二 .搭建流程 1.集群规划 Nimbus Supervisor ...
- mybatis框架(6)---mybatis插入数据后获取自增主键
mybatis插入数据后获取自增主键 首先理解这就话的意思:就是在往数据库表中插入一条数据的同时,返回该条数据在数据库表中的自增主键值. 有什么用呢,举个例子: 你编辑一条新闻,同时需要给该新闻打上标 ...
- WARNING: 'aclocal-1.14' is missing on your system.
源码安装zabbix agent时进行到make install时报如下错误: WARNING: 'aclocal-1.14' is missing on your system. You shoul ...
- Ocelot + Consul实践
关于Consul(https://www.consul.io)是一个分布式,高可用,支持多数据中心的服务发现和配置共享的服务软件,由 HashiCorp 公司用 Go 语言开发, 基于 Mozilla ...
- .net core在Ocelot网关中统一配置Swagger
最近在做微服务的时候,由于我们是采用前后端分离来开发的,提供给前端的直接是Swagger,如果Swagger分布在各个API中,前端查看Swagger的时候非常不便,因此,我们试着将Swagger集中 ...
- asp.net core系列 25 EF模型配置(隐藏属性)
一. 隐藏属性概述 隐藏属性也叫影子属性,该属性不是在.net实体类中定义的属性,而是在EFCore模型中为该实体类型定义的属性.这些属性的值和状态完全在变更跟踪器中维护.它有二个功能:(1)当数据库 ...