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

I basically do this:

export_something | split -b 1000 

which splits export results into xaa, xab, xac file names of just 1000 bytes each

but I want my split output to be included in files with a specific prefix. Usually I just do this:

 split -b <file> <prefix> 

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

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

Is it possible?

+4
source share
4 answers

Yes, - usually used to mean stdin or stdout, whichever makes more sense. In your example

 export_something | split -b 1000 - <prefix> 
+12
source

Use - to enter

Output fragments of INPUT with a fixed size PREFIXaa, PREFIXab, ...;

the default size is 1000 lines, and the default PREFIX is `X. '

Without INPUT or when INPUT -, read standard input.

 export_something | split -b 1000 - <prefix> 
+3
source

use - as input as split --help says

+1
source

You can use the built-in expression (or what it called I will never remember) to export the data directly to the function as a string:

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

Hope this works.

0
source

All Articles