You are not logged in.
Hi!
I was wondering if there is a similar, easy, compress-function to be added to .basrc, like the the extract function at:
https://wiki.archlinux.org/index.php/Core_Utilities
Would be cool to just write:
compress archive.tar.gz [files]
compress archive.zip [files]
Maybe I should learn some bash scripting?
Last edited by penguin (2011-02-24 17:12:26)
Offline
Ehh, gzip?
ᶘ ᵒᴥᵒᶅ
Offline
or tar or zip or rar or p7zip or bzip2
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
I use
alias tg='bsdtar cfz "${1%%/}.tar.gz" "${1%%/}/"'
alias tx='bsdtar cfJ "${1%%/}.tar.xz" "${1%%/}/"'
to compress a folder.
Offline
# roll - archive wrapper
# usage: roll <foo.ext> ./foo ./bar
roll()
{
FILE=$1
case $FILE in
*.tar.bz2) shift && tar cjf $FILE $* ;;
*.tar.gz) shift && tar czf $FILE $* ;;
*.tgz) shift && tar czf $FILE $* ;;
*.zip) shift && zip $FILE $* ;;
*.rar) shift && rar $FILE $* ;;
*) echo "'$1' is not a valid archive type"
esac
}
thayer williams ~ cinderwick.ca
Offline
I just use apack for compressing files and aunpack for extracting them. These tools are part of atool.
Offline
# roll - archive wrapper # usage: roll <foo.ext> ./foo ./bar roll() { FILE=$1 case $FILE in *.tar.bz2) shift && tar cjf $FILE $* ;; *.tar.gz) shift && tar czf $FILE $* ;; *.tgz) shift && tar czf $FILE $* ;; *.zip) shift && zip $FILE $* ;; *.rar) shift && rar $FILE $* ;; *) echo "'$1' is not a valid archive type" esac }
Yes, this was what I had in mind, thanks, I'll try it out.
compress is a real thing. It uses LZW compression.
Oh, yes, you're quite right, I did not think of that.
Offline
Offline
atool seems to be cool. I think I'll use it too now.
To the posts above: The idea is that you don't need to know how to create different archives. You just write the extension and the program magically does what you want:
To create a zip archive of two files `foo' and `bar':
apack myarchive.zip foo bar
I really like this behaviour in imagemagick's convert.
You have some picture in any format and want to create an eps but don't want to look up how to create it?
convert image.extension image.eps
... and it magically works.
ffmpeg works the same way.
฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz
Offline
Wow, this is exactly what I was looking for + some nice image and sound equivalent tips. Thanks!
Last edited by penguin (2011-02-23 16:53:10)
Offline