Skip to content

Instantly share code, notes, and snippets.

@pganti
Created November 17, 2019 16:10
Show Gist options
  • Save pganti/aa8c86315bcce0c96c6027bf5d29a609 to your computer and use it in GitHub Desktop.
Save pganti/aa8c86315bcce0c96c6027bf5d29a609 to your computer and use it in GitHub Desktop.
json splitter
#!/bin/bash
FILENAME=$1
FILESTEM=`echo "$FILENAME" | cut -d'.' -f1`
NUM_FILES=$2
# Hack to get the right number of files
NUM_FILES=$((NUM_FILES-1))
LC=`wc -l $FILENAME | awk '{print $1}'`
LC_FILE=$((LC / NUM_FILES))
echo 'Going to split the files now ...'
split -l $LC_FILE $FILENAME ${FILESTEM}-Part # Split the file into chunks of 20 lines each
echo 'All the split files are now ready'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment