Julian Parker
asked on
URGENT! extract specific directory from gunzip | tar file
All,
I need to extract a directory from a tar.gz file in solaris 9 gtar not available.
I've used gunzip < file.tar.gz | tar xf - ./directory/* but it doesnt work. I'm more used to using tar with the -z option
I need the syntax urgently.
I need to extract a directory from a tar.gz file in solaris 9 gtar not available.
I've used gunzip < file.tar.gz | tar xf - ./directory/* but it doesnt work. I'm more used to using tar with the -z option
I need the syntax urgently.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers wmp, it seemed to be a bit temperamental, the command I used worked sometimes and not others... I eventually did; gunzip < file.tar.gz | tar xf - ./directory
Hi,
glad you found it!
As for the "sometimes not working ..." thing - I obviously didn't think twice about the asterisk in the directory parameter!
This will work only if the shell is able to expand it properly (i.e. to directories/files which exist locally as well as in the archive) .
So if your local ./directory is empty or non-existent, nothing will be extracted - the shell will leave the asterisk as is - and such a file /directory is not present in the archive!
Thx for the points anyway!
wmp
glad you found it!
As for the "sometimes not working ..." thing - I obviously didn't think twice about the asterisk in the directory parameter!
This will work only if the shell is able to expand it properly (i.e. to directories/files which exist locally as well as in the archive) .
So if your local ./directory is empty or non-existent, nothing will be extracted - the shell will leave the asterisk as is - and such a file /directory is not present in the archive!
Thx for the points anyway!
wmp
-c writes the output produced (either the compressed or decompressed file) to standard output and leaves the input files unchanged. When multiple input files are specified, each file is compressed or decompressed independently before being written to the standard output. For better compression, you should concatenate all input file before compressing or decompressing them.
If tar has build-in support for gunzip you can just use:
tar -xzvf MyArchive Source_file
or
tar --extract --gunzip --verbose --file=MyArchive Source_file