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 with 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?
If you use the -l (a lowercase L) option, replace linenumber with the number of lines you'd like in each of the smaller files (the default is 1,000). If you use the -b option, replace bytes with the number of bytes you'd like in each of the smaller files.
To split a file into pieces, you simply use the split command. By default, the split command uses a very simple naming scheme. The file chunks will be named xaa, xab, xac, etc., and, presumably, if you break up a file that is sufficiently large, you might even get chunks named xza and xzz.
Pipe is used to combine two or more commands, and in this, the output of one command acts as input to another command, and this command's output may act as input to the next command and so on. It can also be visualized as a temporary connection between two or more commands/ programs/ processes.
The split command reads the specified file and writes it in 1000-line pieces to a set of output files.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With