Cplit生成的输出文件太少,需要更多 [英] csplit produces too few output files, expecting more
本文介绍了Cplit生成的输出文件太少,需要更多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件,其中包含以下几行:
1291126929200 started 88 videolist15.txt 4 Good 4
1291126929250 59.875 29.0 29.580243595150186 43.016096916037604
1291126929296 59.921 29.0 29.52749417740926 42.78632483544682
1291126929359 59.984 29.0 29.479540161281143 42.56031951027556
1291126929437 60.046 50.0 31.345036510255586 42.682281485516945
1291126932859 started 88 videolist15.txt 5 Good 4
我要拆分包含started
(或videolist
,无关紧要)的每一行的文件。
以下命令仅生成2个输出文件:
$ csplit -k input.txt /started/
然而,我期望更多,如:
$ grep -i started input.txt |wc -l
$ 146
正确的csplit
命令是什么?
推荐答案
在末尾添加{*}
:
$ csplit -k input.txt /started/ {*}
手册页显示:
{*} repeat the previous pattern as many times as possible.
请注意,某些外壳可能会将其解释为特殊模式。在这种情况下,请用"{*}"
引号。
另外,请确保您使用的是csplit
的GNU版本,该版本可在MacOS下与brew install coreutils
一起使用。
演示:
$ cat file
1
foo
2
foo
3
foo
$ csplit -k file /foo/ {*}
2
6
6
4
$ ls -tr xx*
xx03 xx02 xx01 xx00
$ csplit --version
csplit (GNU coreutils) 7.4
这篇关于Cplit生成的输出文件太少,需要更多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文