It queries the cht.sh cheatsheet of various Unix commands. 'cheat tar' prints:
# To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
# To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/
# To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
# To create a .gz archive:
tar -czvf /path/to/foo.tgz /path/to/foo/
# To list the content of an .gz archive:
tar -ztvf /path/to/foo.tgz
# To extract a .bz2 archive:
tar -xjvf /path/to/foo.tgz
# To create a .bz2 archive:
tar -cjvf /path/to/foo.tgz /path/to/foo/
# To extract a .tar in specified Directory:
tar -xvf /path/to/foo.tar -C /path/to/destination/
# To list the content of an .bz2 archive:
tar -jtvf /path/to/foo.tgz
# To create a .gz archive and exclude all jpg,gif,... from the tgz
tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/
# To use parallel (multi-threaded) implementation of compression algorithms:
tar -z ... -> tar -Ipigz ...
tar -j ... -> tar -Ipbzip2 ...
tar -J ... -> tar -Ipixz ...
You do have to be online, but there are ways of downloading the directory of cheat sheets to use offline as well.
function extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
There are man pages though, but still I suppose that might be useful to you.
Anyways, the only options for tar that I commonly use are "c", "x", and "t"; I will use other programs for decompression, and for extracting into a directory, will use cd.
Yes, I suppose you are right, the man pages do not have sufficient examples. So, it is good that they add more there. (The man page still explains what all of the options are; now we have this "cheat sheets" with the examples, too.)
s for silent? I mean, all the text on the page is flashing on and off in sync..the whole page goes black. Its the first ESC code in the downloaded text, I guess..haven't quite figured out how to block that yet. If I then do an 'ls' (100s of files in that dir) it stops flashing, but when I scroll up, the first ls-ed files stay flashing..