Skip to content

Instantly share code, notes, and snippets.

View dannyflax's full-sized avatar

Danny Flax dannyflax

  • Gaithersburg, MD
View GitHub Profile
@dannyflax
dannyflax / partition.sh
Created May 11, 2016 05:11
Partitions a file into X different parts to reduce the file size. Partitions can be concatenated back together by placing them in the same directory and running cat * > originalFile.
#!/bin/bash
file="$1"
num=$2
size="$(wc -c < $file | tr -d '[[:space:]]')"
count="$(expr $size / $num)"
count="$(expr $count + 1)"
for k in $(seq 1 $num); do
i="$(expr $k - 1)"
n="$(expr $i \* $count)"
name="$(echo $file)_file_part_$k"