extracting files from tar
        Posted  
        
            by 
                shantanuo
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by shantanuo
        
        
        
        Published on 2012-04-05T10:37:25Z
        Indexed on 
            2012/04/05
            11:31 UTC
        
        
        Read the original article
        Hit count: 248
        
tar
tar -xvf company_raw_2012-03-16.tgz --directory=/root/test --strip-components=4
I am using the following tar option to remove the leading directories and it is working as expected.
--strip-components NUMBER
strip NUMBER of leading components from file names before extraction
It works only when I know that there are going to be 4 sub-directories. I have tar files and I do not know if there will be 2, 3 or 4 folders inside. How do I strip the entire path and extract files in the given "directory" path.
© Server Fault or respective owner