Code:tar Jxf coreutils-7.2.tar.xz
Code:tar Jxf coreutils-7.2.tar.xz
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.
It works when you use the minus sign: -
tar -Jxf <filename>
Add this to your ~/.bashrc
Now just type "extract filename" and you're golden.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 }
If the file is just something.xz (without .tar) then
will not work. You will get the following error (or similar)Code:tar xvJf something.xz
Instead, just typeCode: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
Code:unxz something.xz![]()
Linux is everywhere.
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.
tar -Jxvf filename.tar.xz
please use capital J
Bookmarks