How do I pipe to Linux split command?
Use -
for stdin:
sort -R somefile | split -l 50 - out
From man split
:
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.
Allowing -
to specify input is stdin is a convention many UNIX utilities follow.
out
is interpreted as input file. You can should a single dash to indicate reading from STDIN
:
sort -R somefile | split - -l 50 out