[plug] re; untar to directory

Luke Dudney dex at wn.com.au
Tue May 6 23:08:18 WST 2003


ok... how about

for i in `tar tfz filename.tar.gz`; do  tar Oxfvz filename.tar.gz $i > `basename $i /etc/mnt/hdd`; done

Cheers
Luke

Jon Miller wrote, On 06/05/03 21:55:

>The second one is what I want except I would get an extracted file(s) as
>such:
>/etc/mnt/hdd/etc/filename instead of /etc/filename.  What I need to get
>rid of is the mnt/hdd which is the leading directories.
>
>On Tue, 2003-05-06 at 20:55, Luke Dudney wrote:
>  
>
>>Not exactly sure what you're trying to do..
>>
>>If you're trying to untar specific files that have leading directories 
>>to a different directory,
>>for i in `tar tfz filename.tar.gz`; do  tar Oxfv filename.tar.gz $i > 
>>/etc/`basename $i`; done
>>
>>If you're trying to untar the entire file to a different directory you 
>>can specify the output directory
>>tar zxfv filename.tar.gz -C /etc
>>
>>Cheers
>>Luke
>>
>>
>>Jon Miller wrote, On 06/05/03 21:00:
>>
>>    
>>
>>>Seems to be the only way to do it.  Iwas hoping I could deleted the leading directories.
>>>
>>>Thanks
>>>
>>>Jon L. Miller, MCNE, CNS
>>>Director/Sr Systems Consultant
>>>MMT Networks Pty Ltd
>>>http://www.mmtnetworks.com.au
>>>
>>>"I don't know the key to success, but the key to failure
>>>is trying to please everybody." -Bill Cosby
>>>
>>>
>>>
>>> 
>>>
>>>      
>>>
>>>>>>billk at iinet.net.au 7:52:26 PM 6/05/2003 >>>
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>err, I usually just untar such things it in /tmp, check em for problems
>>>then copy the files over ...
>>>
>>>or maybe create a temporary symlink to fudge the path if lots of
>>>subdirectories are involved.
>>>
>>>
>>>BillK
>>>
>>>On Tue, 2003-05-06 at 17:05, Jon Miller wrote:
>>> 
>>>
>>>      
>>>
>>>>I have a tarred file that has several directories before the filename:
>>>>ex: /mnt/hdd/etc/filename.tar.gz
>>>>What I need to do is untar the file to:
>>>>/etc/filename
>>>>I'm assuming if I issue the following command it will yield the wrong results
>>>>tar -xzvf filename.tar.gz /etc 
>>>>/etc/mnt/hdd/etc/filename
>>>>Is there a way to strip off the /mnt/hdd?
>>>>
>>>>Thanks
>>>>
>>>>Jon L. Miller, MCNE, CNS
>>>>Director/Sr Systems Consultant
>>>>MMT Networks Pty Ltd
>>>>http://www.mmtnetworks.com.au
>>>>
>>>>"I don't know the key to success, but the key to failure
>>>>is trying to please everybody." -Bill Cosby
>>>>
>>>>
>>>>
>>>>   
>>>>
>>>>        
>>>>



More information about the plug mailing list