I am creating a self-extracting archive and I have got the basic thing going.
However I want to set the command that extracts the archive contents
tail -n+$ARCHIVE_START_LINE $0
into a variable. I can't get this part to work
I have tried many things here - one is shown below for explanation. (Note this is a simplified example and the question is as much about understanding pipes etc as solving the problem.)
#!/bin/bash
export TMPDIR=`mktemp -d /tmp/selfextract.XXXXXX`
ARCHIVE_START_LINE=`awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' $0`
# This works...
tail -n+$ARCHIVE_START_LINE $0 | tar xzv -C $TMPDIR
# .. but this is the kind of thing I want. But it doesn't work...
ARCHIVE_CONTENTS=`tail -n+$ARCHIVE_START_LINE $0`
echo $ARCHIVE_CONTENTS | tar xzv -C $TMPDIR
# I get: gzip: stdin is a multi-part gzip file -- not supported
I am on Ubuntu 12.04
gzip: stdin is a multi-part gzip file -- not supported
– spiderplant0 Apr 12 '15 at 14:53