Results 1 to 2 of 2

Thread: Creating directory inside tar file

  1. #1
    Join Date
    May 2007
    Location
    Crete, Greece
    Beans
    582

    Question Creating directory inside tar file

    Hello all,

    I have a question, any help would be much appreciated.

    Say I have a bunch of files
    Code:
    file1 file2 file3
    among many others in the same folder, and I want to make a tar.gz file of these files. If I remember correctly, I could do something like
    Code:
    tar -czf my_compressed_file.tar.gz file1 file2 file3
    but I would rather put everything in a folder inside the compressed file. In other words the contents of the compressed file should be
    Code:
    my_directory
    my_directory/file1
    my_directory/file2
    my_directory/file3
    Is there a way to do that with one command and without creating temporary folders and stuff?

    Finally, say I have my compressed file as I want, and then I decide that I want to put file4 inside the already created folder my_directory of the compressed file. Can I do that without using many commands again?

    Many thanks in advance
    Last edited by geo909; November 3rd, 2009 at 03:38 AM.

  2. #2
    Join Date
    Jun 2009
    Location
    0000:0400
    Beans
    Hidden!

    Re: Creating directory inside tar file

    You can either make an exclusion list (which accepts wildcards), or if you're going to do this often, make a phony directory with symlinks and use the -h flag to dereference them.

    'man tar' has everything you need to know.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •