LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   strip directory in tar command (https://www.linuxquestions.org/questions/linux-general-1/strip-directory-in-tar-command-901153/)

m_pahlevanzadeh 09-05-2011 01:00 AM

strip directory in tar command
 
Dear all,

You know when use :
Code:

tar -zcvf mytar.tar.gz /var/www/mydir/foo
When decompress mytar.tar.gz, tar creates var directory that contains www/mydir/foo,So i need to when it decompress doesn't create ./var/www/mydir,just creates foo,Of course without cd command while i create tar.gz.
Do you know a useful option in tar command for do it?

zhjim 09-05-2011 01:25 AM

man tar
Code:

--strip-components NUMBER, --strip-path NUMBER
              strip NUMBER  of        leading        components  from  file        names        before
              extraction

              (1) tar-1.14 uses --strip-path, tar-1.14.90+ uses --strip-compo-
              nents



All times are GMT -5. The time now is 12:24 AM.