One Liner to Decompress tar.gz Files

For some reason I can never seem to remember this one liner so I generally have to look it up, or decompress the gzip files, then untar. So I’m documenting it here for my own future reference. (Yeah, Linux experts, keep laughing at me!)

tar xzvf my_dir.tar.gz my_dir

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

May 14, 2009  Tags: , ,   Posted in: Programming & Internet

5 Responses

  1. Jeet from directory submission packages - May 22, 2009

    Wow, I can’t believe that!! You may have to put -xvzf on some systems and last argument my_dir is not really required.

    This works for tar.gz as well as tgz files. If you have tar + bz2 file, you can use xvjf — somehow i always use xvzf and not xzvf.

  2. shae from Linux Forum - September 14, 2009

    I consider myself pretty good with Linux and I still have to look that up when I need it. I think that anymore I do not use it enough to really remember it.

  3. "JimiAdam from Linux guide for beginner" - October 5, 2009

    Yup. You don’t need to provide ‘my_dir’ when extracting a tar archived file. You do that if you are creating a tar archive file such as:

    tar cvf my_dir.tar.gz my_dir1 my_dir2

    Anyway, tar is a great tool for backup too.

  4. Seppo Vuolteenaho from photodeus.com - December 30, 2009

    So ever considered making an alias for it?

    in ~/.bash_rc or ~/bash_aliases (or whatever is suitable for your distro)

    Add for example

    # Extract tar.gz
    alias tarx=’tar xvzf’

    Or name it anything you are sure you will remember :)

  5. john from Orlando vacation homes and florida villas - January 5, 2010

    Being of advanced years I find aliases are the way to go! :)

Leave a Reply