- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Tarring - Relative & Absolute
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 06:38 AM
тАО09-17-2008 06:38 AM
You know when you tar a directory -- say
tar cvf - /opt/myfiles/ourfiles/everyonesfiles/ | compress > files.tar.Z
How do I un-tar this so that it untars this archive within a directory, so that it doesn't tar it from the absolute path.
Sorry.. im not sure if that was clear.. but you must get the picture?? If I untar all that.. it will untar everything in my root dir.
But, let's say I wanted it to be untarr'd in my /export/home/user_admin/ directory??
i.e. it would be /export/home/user_admin/opt/myfiles... etc..
What tar options are there to make sure I can do that?
Many thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 06:47 AM
тАО09-17-2008 06:47 AM
SolutionYou should use relative paths when making 'tar' archives. When confronted with extracting an archive made with absolute paths, use 'pax'.
For example, had I made a 'tar' archive of '/tmp/dummydir' with absolute paths but wanted to extract the contents into '/var/tmp' instead, I could do:
# tar -cvf /tmp/dummydir /tmp/myarchive
# cd /var/tmp;
# pax -r -s ',/tmp/,,' /tmp/myarchive
See the 'pax' manpages.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 06:50 AM
тАО09-17-2008 06:50 AM
Re: Tarring - Relative & Absolute
# cd/opt/myfiles/ourfiles
# tar cvf - everyonesfiles | compress > files.tar.Z
Then when you extract, the directory everyonesfiles will be created in the directory you are currently in.
If you need the whole /opt/myfiles.... structures, just omit the leading '/' and do:
# cd /
# tar cvf - opt/myfiles/ourfiles/everyonesfiles/ | compress > files.tar.Z
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 06:57 AM
тАО09-17-2008 06:57 AM
Re: Tarring - Relative & Absolute
Yes, patrick has a point, but the files are now tar'd and its too late to re-tar them again.
(It was a 1 GB tar file! and that was after compression!).
So, i think my best option is to learn about the pax command.
I'll read the man pages right now on pax, but please do not hesitate to save me time on this reading if you know what the syntax is for using the pax command to untar into a particular directory.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 09:16 AM
тАО09-17-2008 09:16 AM
Re: Tarring - Relative & Absolute
Why not gzip?
> What tar options are there [...]
Which "tar" program are you using? GNU "tar"
offers more than the stock HP-UX "tar".
http://www.gnu.org/software/tar/
http://www.gnu.org/software/tar/manual/
http://www.gnu.org/software/tar/manual/tar.html#SEC108
A Forum search would probably have found all
this, too, of course.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 09:55 PM
тАО09-17-2008 09:55 PM
Re: Tarring - Relative & Absolute
# cd /opt/myfiles/ourfiles
# tar cvf - everyonesfiles | compress > files.tar.Z
You can combine the cd and tar into one and use gzip:
tar -cvf - -C /opt/myfiles/ourfiles everyonesfiles | gzip > files.tar.gz
>if you know what the syntax is for using the pax command to untar into a particular directory.
JRF showed you the syntax:
pax -r -s ',/tmp/,,' /tmp/myarchive
Or in your case:
zcat files.tar.Z | pax -r -v -s ',^/,,'
This will just remove the leading "/".
If you want to remove /opt/myfiles/ourfiles/everyonesfiles/, then:
zcat files.tar.Z | pax -r -v -s ',/opt/myfiles/ourfiles/everyonesfiles/,,'