tar files with absolute pathnames

The pax utility may be used to remove absolute pathnames when extracting files from tar files.

In this example, I want to extract /var/spool/cron/crontabs/root from file.tar into the current directory.

# tar tvf file.tar | grep '/var/spool/cron/crontabs/root'
-rw------- root/sys        1402 2005-11-30 11:57:15 /var/spool/cron/crontabs/root

# pax -rvf file.tar -s,/var/spool/cron/crontabs/,, /var/spool/cron/crontabs/root
root
pax: ustar vol 1, 1548 files, 13987328 bytes read, 0 bytes written.

More information:
Today's 'tar' tip

Back to brandonhutchinson.com.
Last modified: 2008/02/05