LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   remove directory info from tar file (https://www.linuxquestions.org/questions/linux-software-2/remove-directory-info-from-tar-file-578797/)

splunk 08-21-2007 07:30 PM

remove directory info from tar file
 
Hi.

I have some tar files that are 3gb or larger. A listing of their contents shows that they have files that do not need to be backedup. I created a folder named "untarhere" to extract the file contents into. My question/problem is: How do I create a tar archive without it saving the "untarhere" folder name.

Directory layout:
Code:

# cd /untarhere
# ls
2007_Jul_12  2007_Jul_13 2007_Jul_14

If I run
Code:

# tar vcf ./2007_Jul_12.tar.gz /untarhere/2007_Jul_12
and then
Code:

# tar tf ./2007_Jul_12.tar.gz
I get
Code:

/untarhere/2007_Jul_12/
/untarhere/2007_Jul_12/file1
/untarhere/2007_Jul_12/file2
/untarhere/2007_Jul_12/directory1
/untarhere/2007_Jul_12/directory2
...

The output I want to see is this:
Code:

/2007_Jul_12/
/2007_Jul_12/file1
/2007_Jul_12/file2
/2007_Jul_12/directory1
/2007_Jul_12/directory2
...

I do not want "/untarhere" to be saved in the tar file. How do I tell tar to do this?

gilead 08-21-2007 07:52 PM

Try using -C to change to untarhere first and then just specify the sub-directory of untarhere to back up:
Code:

tar -vcf ./2007_Jul_12.tar.gz -C /untarhere 2007_Jul_12
Does that do what you need?

splunk 08-22-2007 03:24 PM

Thanks
 
Does what I need it to.


All times are GMT -5. The time now is 11:51 AM.