Created
April 27, 2012 15:45
-
-
Save bgamari/2510284 to your computer and use it in GitHub Desktop.
Script to split file into chunks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
nchunks=$1 | |
file=$2 | |
nlines=$(wc -l $file) | |
let n=$nlines/$nchunks | |
for i in $(seq 1 $nchunks); do | |
let startline=$i*$n | |
tail -n +$startline $file | head -n $n > $file.$i | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/bin/bash
nchunks=$1
file=$2
nlines=$(wc -l $file)
let n=$nlines/$nchunks
split -l $n $file