I have some snappy files that I'd like to be able to compress/decompress on the command line. I didn't see any obvious tools, is there's something standard that people use for snappy?
2 Answers
Here's a gem that I found long back on the arch forums, before you use it you should have 7zip
and unrar
or other tools to handle the formats you need to extract.
# File extractor
# usage: extract <file>
extract ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $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 ;;
*.snz) snunzip $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
To use it, you must add this to your .bash_profile
or .profile
after that is done you can use extract
to decompress all sort of archives from the command line. The syntax is extract name-of-archive
You can use it with snappy too, you need to install this however before it'll work.
-
The question is about a specific file format, snappy, which your answer doesn't mention. Dec 14, 2012 at 19:08
-
@sierrasdetandil have added the details to make it work with snappy too, the objective of my answer was to share a tip that I personally dind very useful and can be extended to virtually any file format.– nikhilDec 15, 2012 at 11:09
-
I understand, I was just pointing out that it didn't answer the question. I've removed my downvote now that it does. Dec 15, 2012 at 18:38
-
-
2uugh, why not start the answer with install
snzip
. you mention7zip
andunrar
which have nothing to do with snappy.– swdevApr 2, 2021 at 1:08
This is exactly feature request #34 in the issue tracker of Snappy. See the comments of December 3 for a Python command line version available on Github.