【问题标题】:How to use csplit command to split a log file by day?如何使用 csplit 命令按天拆分日志文件?
【发布时间】:2015-08-08 09:38:48
【问题描述】:

我有一个如下的日志文件:

Jan 01  This the log of this day.
Jan 01  This the log of this day.
Jan 01  This the log of this day.
Jan 01  This the log of this day.
Jan 01  This the log of this day.
Jan 01  This the log of this day.
Jan 01  This the log of this day.
Jan 01  This the log of this day.
Jan 01  This the log of this day.
Jan 01  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 02  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.
Jan 03  This the log of this day.

如何按天拆分文件?我使用了命令:

csplit log /*Jan 01*/ /*Jan 02*/ /*Jan 03*/

但有错误:

csplit: /*Jan: closing delimiter '/' missing

所以任何人都可以请告诉我如何解决这个问题?提前致谢。

【问题讨论】:

    标签: linux csplit


    【解决方案1】:

    shell 将/*Jan 视为一个参数,01*/ 视为另一个参数,依此类推。您需要引用嵌入空格的参数。

    csplit log '/*Jan 01*/' '/*Jan 02*/' '/*Jan 03*/'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-24
      • 1970-01-01
      • 2014-02-17
      • 1970-01-01
      相关资源
      最近更新 更多