I'm trying to split a long csv into files of 500 lines each. I want the output files in a specific directory, and I want to leave off the first line of the csv.
I can use split
and leave off the first line of the csv by piping the output of cat
:
cat file.csv | tail -n +2 | split -l 500
And I can specify the output directory like so:
split -l 500 file.csv /mnt/outdir
But when I try something like this:
cat file.csv | tail -n +2 | split -l 500 /mnt/outdir
It thinks that /mnt/outdir
is the file I am trying to split and tells me split: /mnt/outdir: Is a directory
.
So how to I somehow pipe output into the split
command, while specifying an output directory?