Bash example

Şuraya atla: kullan, ara
#!/bin/bash
# usage = $0 some.app infile outfile
declare -i APPSIZE # Size of .app file
declare -i OFFSET  # amount of file discounted already
declare -i LENGTH  # length of the item we are looking at
APPSIZE=$(ls -l $1 | awk '{print $5}')
# this offset skips our bash and points to the start of the ar entries
OFFSET=40
DONE=0
#loop until the next entry is the infile we want
while (!( [ "$DONE" = "1" ] )) ; do
# would be nicer if we could just cull the one line
# I only know perl well enough :-)
# does dd skip really just jump to the correct location?
# or does it read through the contents leading up to what you want?
# this gets the ar entry for the next item
echo "$1 $OFFSET"
NEXT=$(dd if=$1 bs=1 count=60 skip=$OFFSET 2>/dev/null)
# this gets the length of the next item
LENGTH=$(echo $NEXT | awk '{print $6}')
# the ar entry itseld is 60 bytes
OFFSET=$OFFSET+60
# if we have either got the file we want or have run out of file
if ((echo $NEXT | grep ^$2\/>/dev/null 2>/dev/null)||([ "$OFFSET" == "$APPSIZE" ])); then
DONE=1
else
# skip past this item on next loop
OFFSET=$OFFSET+$LENGTH
fi
done
# we know where it starts and it's length so dump it to our final argument
dd if=$1 bs=1 count=$LENGTH skip=$OFFSET > $3 2>/dev/null