Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all, I need to create .tar.gz a directory but when i am tar a directory with full path, its get compressed as full path. when untar the same directory, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2014
    Posts
    4

    Need help to create .tar.gz with full path


    Hi all,

    I need to create .tar.gz a directory but when i am tar a directory with full path, its get compressed as full path.

    when untar the same directory, its get extracted as full path location.


    Ex:-


    Source File location:-
    *********************

    /tmp/test/backup/


    Backup Directory:-
    *****************

    /root/Desktop/backup.tar.gz


    tar -czvf /root/Desktop/backup.tar.gz /tmp/test/backup



    After that, when i am untar the same file its get extracted as /root/Desktop/backup/ directory.

    But i need to extract as backup/ directory alone.


    Issue is when i am creating tar with full path, its get compressed as full path .tar.gz file. I dont want to tar as full path.

    Need to filter that full path when creating .tar.gz file.

    Please help me on this...


    Thanks,

  2. #2
    fd0
    fd0 is offline
    Just Joined!
    Join Date
    Jul 2014
    Posts
    6
    Navigate to the directory in which backup resides then make your tar archive.
    Code:
    cd /tmp/test
    tar -czvf /root/Desktop/backup.tar.gz backup

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,753
    Read the tar man pages - there are a gazillion tar options to deal with this stuff.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. $spacer_open
    $spacer_close

Posting Permissions

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