Friday, May 3, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 7202  / 2 Years ago, sun, may 22, 2022, 11:16:27

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?


More From » command-line

 Answers
6

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.


[#33687] Monday, May 23, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
irtuallyefu

Total Points: 429
Total Questions: 97
Total Answers: 119

Location: Hong Kong
Member since Tue, Oct 19, 2021
3 Years ago
irtuallyefu questions
;