开发者

How can I change where unix pipe sends its results for the split command?

Basically I'm doing this:

export_something | split -b 1000

which splits the results of the export into files names xaa, xab, xac all 1000 bytes each

but I want my output from split to go into files wit开发者_运维问答h a specific-prefix. Ordinarily I'd just do this:

split -b <file> <prefix>

but there's no flag for prefix when you're piping to it. What I'm looking for is a way to do this:

export_something | split -b 1000 <output-from-pipe> <prefix>

Is that possible?


Yes, - is commonly used to denote stdin or stdout, whichever makes more sense. In your example

export_something | split -b 1000 - <prefix>


Use - for input

Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...;

default size is 1000 lines, and default PREFIX is `x'.

With no INPUT, or when INPUT is -, read standard input.

export_something | split -b 1000 - <prefix>


use - as input as split --help says


You could use an inline expression (or whatever it's called, I can never remember) to export the data directly into the function as a string:

 split -b 1000 "`export_something`" <prefix>

Hope this works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜