How do I use pax to extract to a specific directory

654 views Asked by At

I am currently using tar to extract files...

tail -n+$ARCHIVE_START_LINE $archiveFilename | tar -xzm -C /

I need to use pax instead of tar, so something like ...

tail -n+$ARCHIVE_START_LINE $archiveFilename | gzip -d | pax -r 

This extracts to the current directory. Is there a way to extract to a specific directory (root in my case)? (I have tried ... pax -r > / but that gave an error.)

1

There are 1 answers

0
nneonneo On BEST ANSWER

The simplest solution is just to wrap pax in a subshell:

tail -n+$ARCHIVE_START_LINE $archiveFilename | gzip -d | ( cd / ; pax -r )