Currently, my bash script splits by number of lines. However, I'd like to split a file into X pieces, each of those having total lines equal to the file length divided by X. The script is run as follows:
So far, in the script, I have this:
INPUT_FILE=$1 SPLIT_NUM_THREADS=15 TOTAL_LINES=$(wc -l < $INPUT_FILE) SPLIT_NUM=$( echo "scale=6; $TOTAL_LINES / $SPLIT_NUM_THREADS" | bc)
The following issues exist:
- Using $INPUT_FILE to get TOTAL_LINES gets me the error "ambiguous redirect", but using simply "input.tsv" does not. What's wrong there?
- SPLIT_NUM is a float, how do I convert it to an int so it can split by lines?
How can I resolve these issues and split a file by number of pieces?