【问题标题】:How to find files that contain MULTIPLE newlines at their end?如何查找末尾包含多个换行符的文件?
【发布时间】:2015-10-26 19:28:27
【问题描述】:

我想查找所有内容末尾有多个换行符的文件。

这怎么可能?

【问题讨论】:

  • 你为什么需要这个?

标签: macos file unix find newline


【解决方案1】:

此 bash 命令打印当前目录及其子目录中的所有文件,这些文件在一行或多行的序列(即至少两个 \n 的序列)之后以至少一个空行结尾:

 find . -type f -print | while read a; do tail -2 "$a" | ( read x && read y && [ x"$x" = x ] && echo "$a" ); done

【讨论】:

    【解决方案2】:

    仅供参考:可以使用正则表达式搜索词 \n+\n\Z 使用 PHPStorm 进行搜索

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-06
      • 2018-08-31
      • 2022-01-02
      • 2013-10-08
      • 2014-03-10
      • 1970-01-01
      • 2013-04-28
      相关资源
      最近更新 更多