Created
July 31, 2019 12:43
-
-
Save v-sukt/c895524b7793932fa8556a6e5f53b720 to your computer and use it in GitHub Desktop.
Split file on basis of lines - like big csv file
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
#!/usr/bin/env bash | |
#cp ${1} ${1}-$(date +%s).bkp | |
lines=2 # indicate the number of lines each split should have | |
last_line=1 | |
count=0 | |
end=$(wc -l <${1}) | |
while [[ ${last_line} -lt ${end} ]]; do | |
tail -n +${last_line} $1 | head -n ${lines} > ${1}_split_${count} | |
last_line=$((last_line+lines)) | |
count=$((count+1)) | |
done | |
tail -n +${last_line} $1 > ${1}_split_${count} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment