Results 1 to 8 of 8

Thread: TIP: extract .xz format

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Beans
    207

    TIP: extract .xz format

    Code:
    tar Jxf coreutils-7.2.tar.xz

  2. #2
    Join Date
    Jan 2009
    Beans
    261
    Distro
    Ubuntu 12.04 Precise Pangolin

    tar: invalid option -- J

    I tried your code. I got this error message.
    Code:
    ~$ tar Jxf coreutils-7.4.tar.xz
    tar: invalid option -- J
    Try `tar --help' or `tar --usage' for more information.

  3. #3
    Join Date
    Feb 2006
    Location
    Ireland
    Beans
    856
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: tar: invalid option -- J

    It works when you use the minus sign: -
    tar -Jxf <filename>

  4. #4
    Join Date
    Dec 2006
    Location
    /dev/null
    Beans
    351

    Re: TIP: extract .xz format

    Add this to your ~/.bashrc

    Code:
    extract () {
       if [ -f $1 ] ; then
           case $1 in
    	*.tar.bz2)	tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
    	*.tar.gz)	tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
    	*.tar.xz)	tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
    	*.bz2)		bunzip2 $1 && cd $(basename "$1" /bz2) ;;
    	*.rar)		unrar x $1 && cd $(basename "$1" .rar) ;;
    	*.gz)		gunzip $1 && cd $(basename "$1" .gz) ;;
    	*.tar)		tar xvf $1 && cd $(basename "$1" .tar) ;;
    	*.tbz2)		tar xvjf $1 && cd $(basename "$1" .tbz2) ;;
    	*.tgz)		tar xvzf $1 && cd $(basename "$1" .tgz) ;;
    	*.zip)		unzip $1 && cd $(basename "$1" .zip) ;;
    	*.Z)		uncompress $1 && cd $(basename "$1" .Z) ;;
    	*.7z)		7z x $1 && cd $(basename "$1" .7z) ;;
    	*)		echo "don't know how to extract '$1'..." ;;
           esac
       else
           echo "'$1' is not a valid file!"
       fi
     }
    Now just type "extract filename" and you're golden.

  5. #5
    Join Date
    Feb 2007
    Location
    Slovenia
    Beans
    38
    Distro
    Kubuntu

    Talking Re: TIP: extract .xz format

    If the file is just something.xz (without .tar) then
    Code:
    tar xvJf something.xz
    will not work. You will get the following error (or similar)
    Code:
    tar: Record size = 16 blocks
    tar: This does not look like a tar archive
    tar: Skipping to next header
    tar: Exiting with failure status due to previous errors
    Instead, just type
    Code:
    unxz something.xz
    Linux is everywhere.

  6. #6
    Join Date
    Oct 2004
    Beans
    87

    Re: TIP: extract .xz format

    This is my extract script that uses MIME to determine the format plus it has protection for extracting into the current dir:

    https://github.com/lzap/dancepill/blob/master/e

    Patches welcome.

  7. #7
    Join Date
    Mar 2013
    Beans
    1

    solved: TIP: extract .xz format

    tar -Jxvf filename.tar.xz
    please use capital J

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
  •