如何使用csplit命令按天分割日志文件



我有一个日志文件如下:

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.

如何按天分割文件?我使用command:

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

但是有错误:

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

所以谁能告诉我如何解决这个问题?

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

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

最新更新