I'm writing a script that is trying to insert a directory name into a pax command and I'm not sure how to get the syntax correct. This is what I'm trying, but it seems to be treating the $DIRNAME as part of the regex string.
DIRNAME=$(tar -tvf $1 | head -1 | sed -e 's:^.* \([^/]*\)/.*$:\1:')
pax -r -f $1 -s'/$DIRNAME\/upload\///'
Thanks!