You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
519 B
Plaintext
29 lines
519 B
Plaintext
9 years ago
|
#!/bin/bash
|
||
|
#
|
||
9 years ago
|
# Quick and dirty extracter to slice out a section of a binary file
|
||
9 years ago
|
# Copyright (C) 2016 Hamish Coleman
|
||
9 years ago
|
#
|
||
|
# TODO:
|
||
|
# - a tool that is portable to Windows
|
||
|
# - should output dependancy information
|
||
|
|
||
9 years ago
|
INFOFILE="$1"
|
||
|
if [ ! -r "$INFOFILE" ]; then
|
||
|
echo Need file with source and offset info
|
||
9 years ago
|
exit 1
|
||
|
fi
|
||
9 years ago
|
shift
|
||
9 years ago
|
|
||
9 years ago
|
OUT="$1"
|
||
|
if [ -z "$OUT" ]; then
|
||
|
echo Need output filename
|
||
9 years ago
|
exit 1
|
||
|
fi
|
||
|
|
||
|
read SOURCE OFFSET LENGTH <"$INFOFILE"
|
||
|
|
||
|
set -x
|
||
|
|
||
9 years ago
|
dd if=$SOURCE bs=$[$OFFSET] skip=1 | dd bs=$[$LENGTH] count=1 of="$OUT"
|
||
9 years ago
|
|