You are not logged in.

#1 2011-02-09 15:04:14

penguin
Member
From: Gotham City
Registered: 2010-12-31
Posts: 163

[SOLVED]handy compress function similar to extract in Core Utilities?

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? wink

Last edited by penguin (2011-02-24 17:12:26)

Offline

#2 2011-02-09 15:05:45

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

Ehh, gzip?


ᶘ ᵒᴥᵒᶅ

Offline

#3 2011-02-09 15:20:07

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

or tar or zip or rar or p7zip or bzip2


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#4 2011-02-09 15:24:45

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

compress is a real thing. It uses LZW compression.

But really, use tar with a bzip/gzip/xz filter.

Offline

#5 2011-02-09 15:41:48

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

I use

alias tg='bsdtar cfz "${1%%/}.tar.gz" "${1%%/}/"'
alias tx='bsdtar cfJ "${1%%/}.tar.xz" "${1%%/}/"'

to compress a folder.

Offline

#6 2011-02-09 15:55:34

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

# 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

#7 2011-02-09 19:19:17

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

I just use apack for compressing files and aunpack for extracting them. These tools are part of atool.

Offline

#8 2011-02-10 09:57:51

penguin
Member
From: Gotham City
Registered: 2010-12-31
Posts: 163

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

thayer wrote:
# 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.

falconindy wrote:

compress is a real thing. It uses LZW compression.

Oh, yes, you're quite right, I did not think of that.

Offline

#9 2011-02-22 06:50:42

alterecco
Member
Registered: 2009-07-13
Posts: 152

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

Offline

#10 2011-02-22 09:46:59

Cdh
Member
Registered: 2009-02-03
Posts: 1,098

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

atool seems to be cool. I think I'll use it too now. smile
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

#11 2011-02-23 16:52:34

penguin
Member
From: Gotham City
Registered: 2010-12-31
Posts: 163

Re: [SOLVED]handy compress function similar to extract in Core Utilities?

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

Board footer

Powered by FluxBB