- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: TAR - simple extraction
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
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
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
10-02-2007 01:21 AM
10-02-2007 01:21 AM
I am extracting a tar file,
I am using
"tar -xvf tarfilename"
it extracts files to the original location.
I want to extract files to a CWD.
Should the syntax be something like such?
"tar -xvf tarfilename newdir"
or
"tar -xvf tarfilename . "
For some reason the pathing in the tar file pushed files to a file system I have watch fairly closely for disk space, I'd prefer to extract to another location.
Any quick insight deeply appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 01:29 AM
10-02-2007 01:29 AM
Re: TAR - simple extraction
you can move the tar archive where you want to extract the files and then just to execute
tar -xf tarfilename
in this directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 01:30 AM
10-02-2007 01:30 AM
Re: TAR - simple extraction
do a tar tvf tarfilename to see.
If so, you will need to use pax to extract it to a new directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 01:36 AM
10-02-2007 01:36 AM
Re: TAR - simple extraction
there is a terrible hack:
First, cd to the direcotry, to which you want to extract.
However, the command below will restore the only the basename of the selected files:
$ pax -rv -s'/^\///' < tarfilename.tar
Perhaps other members have better - and not so quick - insights!
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 01:36 AM
10-02-2007 01:36 AM
Re: TAR - simple extraction
the original tar command to create the archive is full path to our db export locations.
/mount/export/dbs/dbname/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 01:37 AM
10-02-2007 01:37 AM
Re: TAR - simple extraction
You need to look at using pax to extract the files to another directory.
man pax
...
To read the archive a.pax, with all files rooted in the directory /usr
in the archive extracted relative to the current directory, enter:
pax -r -s ',//*usr//*,,' -f a.pax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 01:49 AM
10-02-2007 01:49 AM
Re: TAR - simple extraction
> archive is full path to our db export
> locations.
>
> /mount/export/dbs/dbname/
I trust that it's now clear why this was
probably unwise.
"pax" offers that "-s" option already
mentioned. GNU "tar" offers
"--strip-components=number" and
"--transform=sed-expr" (sounds like pax's
"-s"), either of which can help in this
situation.
http://www.gnu.org/software/tar/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 02:05 AM
10-02-2007 02:05 AM
Re: TAR - simple extraction
in your scenario:
pax -r -s ',//*usr//*,,' -f a.pax
If I modify this command to reflect
Say for example
pax -r -s ',//*exportfs//*,,' -f tarfile.tar
should take any files in the tarfile.tar and string off the leading exportfs? I have a deeply embedded directory structure..
/exportfs/dbexport/onconfig.pei/distname/dbname.exp/
How will that effect the result of the pax command ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 05:24 AM
10-02-2007 05:24 AM
Re: TAR - simple extraction
>should take any files in the tarfile.tar and string off the leading exportfs? I have
> a deeply embedded directory structure..
>/exportfs/dbexport/onconfig.pei/distname/dbname.exp/
>How will that effect the result of the pax command ?
Are you trying to remove the leading "/exportfs" string and then extracting the tar archive to the current working directory with the rest of the path intact viz.,
# pax -v -r -f tarfile.tar -s?/exportfs/??g
strips off the leading "/exportfs/" string and extracts the remaining path name i.e. "dbexport/onconfig.pei/distname/dbname.exp/" in the CWD. Is that what you want?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 05:38 AM
10-02-2007 05:38 AM
Re: TAR - simple extraction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 05:39 AM
10-02-2007 05:39 AM
Re: TAR - simple extraction
The / is the absolute pathname and tar has no options to restore that file to another location. Now there are tar enhancements such as gtar that do indeed have (non-standard) options to allow for this and if you must stay with tar, then downloading a copy of gtar is worth the effort. Be sure that you don't install gtar so it replaces /usr/bin/tar. You need to maintain each program separately.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 05:42 AM
10-02-2007 05:42 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2007 05:46 AM
10-02-2007 05:46 AM
Re: TAR - simple extraction
Thanks All.