Skip to content

Instantly share code, notes, and snippets.

@jrunning
Created January 17, 2012 17:49
Show Gist options
  • Select an option

  • Save jrunning/1627806 to your computer and use it in GitHub Desktop.

Select an option

Save jrunning/1627806 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
# Change this to what you want the output files to be named (don't remove
# the %04s part--it adds the number to each filename).
out_file_name="out_file_%04s.baz"
count=0
while read offset image_size
do
count=$((count + 1))
# NOTE: To see what commands will be run without actually running
# them put "echo " before the line below, e.g. "echo dd if=$1 ...".
dd if=$1 of=$(printf $out_file_name $count) ibs=1 skip=$offset count=$image_size
done < $2
0 179546
179546 180260
359806 181070
540876 182138
723014 182616
905630 183266
1088896 183740
... ...

Usage

$ chmod a+x matts_split.sh
$ ./matts_split.sh path/to/blob_file.baz path/to/tab_separated_offsets.tab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment