gzip 的管道输出到 csplit

pipe output of gzip into csplit

此命令有效:

csplit really_big_file.txt -f ../dump/really_big_file_ /^H\|756\|/ {*}

但是这个命令:

gzip -dc  really_big_file.txt.gz | csplit -f ../dump/really_big_file_ /^H\|756\|/ {*}

产量:

csplit: cannot open '/^H|756|/' for reading: No such file or directory

如何将 gzip 的输出通过管道传输到 csplit?

man csplit 中说文件总是在模式之前:

SYNOPSIS

   csplit [OPTION]... FILE PATTERN...

所以应该是:

gzip -dc  really_big_file.txt.gz | csplit -f ../dump/really_big_file_ - /^H\|756\|/ {*}

示例:

$ gzip -dc inputfile.txt.gz
abc
searchstring
def
searchstring
egh
searchstring
$ mkdir split
$ gzip -dc inputfile.txt.gz | csplit  -f split/file - /searchstring/ {*}
$ ls -Al split/
total 16
-rw-r--r-- 1 ja users  4 Sep 21 17:53 file00
-rw-r--r-- 1 ja users 17 Sep 21 17:53 file01
-rw-r--r-- 1 ja users 17 Sep 21 17:53 file02
-rw-r--r-- 1 ja users 13 Sep 21 17:53 file03
$ cat split/*
abc
searchstring
def
searchstring
egh
searchstring