今天遇到一个特殊需求,需要找到某天(例如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如何查找某个时间点后生成的空文件的更多相关文章

  1. Linux查找某个时间点后生成的文件(转)

    需要找到某天(例如2017-04-13)以及这之后生成的空文件.那么这个要怎么处理呢?这个当然是用find命令来解决.如下所示, -mtime -5表示查找距现在5*24H内修改过的文件 -type ...

  2. Linux如何查找处理文件名后包含空格的文件

    Linux如何查找处理文件名后包含空格的文件   当Linux下文件名中出现空格这类特殊情况话,如何查找或确认那些文件名后有空格呢? 又怎么批量替换处理掉这些空格呢? 方法1: 输入文件名后使用Tab ...

  3. linux下php增加curl扩展,生成curl.so文件

    进入php源代码目录 cd /php5.6.9/ext/curl 执行生成so文件编译模式 /usr/local/php/bin/phpize 编译curl扩展 ./configure --with- ...

  4. linux中ping带时间及打印内容到文件

    ping命令就不多说了,-i是时间间隔,-c是ping的次数 这种是每隔30秒ping一次,并在后面显示时间: ping 192.168.30.123 -i 30 | awk '{ print $0& ...

  5. linux中find批量删除空文件及空文件夹

    linux下批量删除空文件(大小等于0的文件)的方法  代码如下 复制代码 find . -name "*" -type f -size 0c | xargs -n 1 rm -f ...

  6. Linux如何查找文件的创建时间

    Linux的文件能否找到文件的创建时间取决于文件系统类型,在ext4之前的早期文件系统中(ext.ext2.ext3),文件的元数据不会记录文件的创建时间,它只会记录访问时间.修改时间.更改时间(状态 ...

  7. Linux上查找

    locate 用法:locate filename locate是Linux系统中的一个查找(定位)文件命令,和find命令等找寻文件的工作原理类似,但locate是通过生成一个文件和文件夹的索引数据 ...

  8. Linux下查找文件:which、whereis、locate、find 命令的区别

    我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索.which       查看可执行文件的位置,通过环境变量查whereis    查看文件的位置,通过数据库查,每 ...

  9. linux下查找某个文件位置的方法

    一.通过文件名查找法: 举例说明,假设你忘记了httpd.conf这个文件在系统的哪个目录 下,甚至在系统的某个地方也不知道,则这是可以使用如下命令: find / -name httpd.conf ...

随机推荐

  1. [Swift]LeetCode1006. 笨阶乘 | Clumsy Factorial

    Normally, the factorial of a positive integer n is the product of all positive integers less than or ...

  2. HBase之Table.put客户端流程(续)

    上篇博文中已经谈到,有两个流程没有讲到.一个是MetaTableAccessor.getRegionLocations,另外一个是ConnectionImplementation.cacheLocat ...

  3. scala调用Linux命令行

    在 scala 里面存在 调用 Linux 命令行的函数: import scala.sys.process._ 执行的方法也不难: import scala.sys.process._ /** * ...

  4. Python内置函数(64)——tuple

    英文文档: The constructor builds a tuple whose items are the same and in the same order as iterable‘s it ...

  5. 从源码分析如何优雅的使用 Kafka 生产者

    前言 在上文 设计一个百万级的消息推送系统 中提到消息流转采用的是 Kafka 作为中间件. 其中有朋友咨询在大量消息的情况下 Kakfa 是如何保证消息的高效及一致性呢? 正好以这个问题结合 Kak ...

  6. AttributeError: module 'pip' has no attribute 'main'

    Pycharm在运行pip安装模块是报错如下: 解决方法: 找到安装路径下的packaging_tool.py文件修改如下: 我的路径为D:\Program Files\JetBrains\PyCha ...

  7. 编译安装mysql5.7.24踩的坑

    1.报错如下:CMake Error at cmake/boost.cmake:76 (MESSAGE):  You can download it with -DDOWNLOAD_BOOST=1 - ...

  8. C#版 - Leetcode 215. Kth Largest Element in an Array-题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - L ...

  9. replugin插件化,插件转场动画失效的问题解决

    说明 随着应用功能的丰富,Android程序的安装包也逐渐变大,这成为应用程序现有框架下难以摆脱的瓶颈.所以引入了rePlugin插件化框架,将应用按功能拆分为插件,以此减小apk的大小并同时增加应用 ...

  10. Kali 无法正常上网问题

    有时候我们会突然发现我们的kali不能够正常上网,在终端使用ping 命令对其进行检查,显示网络不可达, 然后使用ifconfig,可以看到没有正在工作的网卡,只有localhost 接着使用ifco ...