LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-05-2011, 01:00 AM   #1
m_pahlevanzadeh
Member
 
Registered: Sep 2002
Location: Iran/Tehran
Distribution: Debian
Posts: 94

Rep: Reputation: 28
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?
 
Old 09-05-2011, 01:25 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tar-command not found while compiling glibc-libidn-2.7.tar.bz2 of lfs6.3 aditya_gpch Linux From Scratch 1 05-13-2008 11:27 PM
strip command varun_shrivastava Programming 3 09-03-2007 11:04 AM
Bash script to strip a certain directory out of directories in a directory? rylan76 Linux - General 3 08-29-2006 11:35 AM
Strip leading dot in filepaths (in tar archive) EcceVery Debian 2 04-13-2005 07:47 PM
strip command? blackzone Linux - General 2 07-09-2004 03:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration