Suramya's Blog : Welcome to my crazy life…

January 22, 2006

Extract a tar archive relative to the current directory

Filed under: Linux/Unix Related,Tutorials — Suramya @ 9:02 PM

How to extract a tar that looks like relative to the current directory:

$ tar -tvf MyArchive.tar
-rw-r–r– 100/100 58239140 Jan 20 05:17 2006 /home/suramya/bin/File1.dat
-rw-r–r– 100/100 56660587 Jan 19 16:07 2006 /home/suramya/bin/File2.dat

I don’t want to extract these files to /home/suramya/bin I want them relative to my current directory. The GNU tar program does this automatically but the Solaris version doesn’t. To fix this problem use the following command:

pax -r -s ',^/,,' -f MyArchive.tar

This will extract MyArchive.tar in the current directory (By creating a home/suramya/bin directory in the current directory)

Tip courtesy: Solaris IAOQ

– Suramya

« Newer Posts

Powered by WordPress