tar+gz in one shot

tar+gz in one shot

Post by Ravi Parim » Wed, 27 Mar 2002 13:11:23



Hi,

        In tcsh, I have an alias which is like this :
alias targz tar cvf - !$ | gzip !$.tar.gz

        I cannot implement a similar alias in bash to tar and
gzip a directory in one command. Even a simple alias like
alias tar='tar cvf- $1.tar $1'

doesn't seem to work.

Can anyone help ?
thanks,
--ravi

 
 
 

tar+gz in one shot

Post by Faux_Pseud » Wed, 27 Mar 2002 13:53:52


--(Once apon a time, in comp.unix.shell,)--
                --(Ravi Parimi said it like only they can.)--

Quote:> Hi,

>    In tcsh, I have an alias which is like this :
> alias targz tar cvf - !$ | gzip !$.tar.gz

>    I cannot implement a similar alias in bash to tar and
> gzip a directory in one command. Even a simple alias like
> alias tar='tar cvf- $1.tar $1'

> doesn't seem to work.

> Can anyone help ?
> thanks,
> --ravi

does tcsh allow for functions in your rc file?
secondly why arn't you useing the z flag on tar?  It will gzip it
automaticaly.

targz() {
tar cfvz $1 $1.tar.gz

Quote:}

--

It's a damn poor mind that can only think of one way to spell a word.
        - Andrew Jackson
UIN=66618055

 
 
 

tar+gz in one shot

Post by Cyrille MAUCC » Wed, 27 Mar 2002 16:30:50


Hi,

if you don't have a tar version that supports -z flag, you can do:
tar -cf - $tobetarred | gzip -9 - > $targzfile

Hope it helps
Cyrille



Quote:> Hi,

> In tcsh, I have an alias which is like this :
> alias targz tar cvf - !$ | gzip !$.tar.gz

> I cannot implement a similar alias in bash to tar and
> gzip a directory in one command. Even a simple alias like
> alias tar='tar cvf- $1.tar $1'

> doesn't seem to work.

> Can anyone help ?
> thanks,
> --ravi

 
 
 

tar+gz in one shot

Post by Ravi Parim » Wed, 27 Mar 2002 16:30:09



> --(Once apon a time, in comp.unix.shell,)--
>            --(Ravi Parimi said it like only they can.)--
> > Hi,

> >       In tcsh, I have an alias which is like this :
> > alias targz tar cvf - !$ | gzip !$.tar.gz

> >       I cannot implement a similar alias in bash to tar and
> > gzip a directory in one command. Even a simple alias like
> > alias tar='tar cvf- $1.tar $1'

> > doesn't seem to work.

> > Can anyone help ?
> > thanks,
> > --ravi

> does tcsh allow for functions in your rc file?
> secondly why arn't you useing the z flag on tar?  It will gzip it
> automaticaly.

> targz() {
> tar cfvz $1 $1.tar.gz
> }

I think tar cvfz works only with gnu tar. I get the following error when i
try to run on SunOS 5.8
$) tar cvfz mail.tar.gz mail/
tar: z: unknown option

thanks,
--ravi

- Show quoted text -

> --

> It's a damn poor mind that can only think of one way to spell a word.
>         - Andrew Jackson
> UIN=66618055

 
 
 

tar+gz in one shot

Post by Faux_Pseud » Thu, 28 Mar 2002 02:45:24


--(Once apon a time, in comp.unix.shell,)--
                --(Ravi Parimi said it like only they can.)--


>> --(Once apon a time, in comp.unix.shell,)--
>>                --(Ravi Parimi said it like only they can.)--
>> > Hi,

>> >   In tcsh, I have an alias which is like this :
>> > alias targz tar cvf - !$ | gzip !$.tar.gz

>> >   I cannot implement a similar alias in bash to tar and
>> > gzip a directory in one command. Even a simple alias like
>> > alias tar='tar cvf- $1.tar $1'

>> > doesn't seem to work.

>> > Can anyone help ?
>> > thanks,
>> > --ravi

>> does tcsh allow for functions in your rc file?
>> secondly why arn't you useing the z flag on tar?  It will gzip it
>> automaticaly.

>> targz() {
>> tar cfvz $1 $1.tar.gz
>> }

> I think tar cvfz works only with gnu tar. I get the following error when i
> try to run on SunOS 5.8
> $) tar cvfz mail.tar.gz mail/
> tar: z: unknown option

targz() {
tar cfv $1 $1.tar
gzip $_

Quote:}

Woops that is very bashish let me translate that.

targz() {
tar cfv $1 $1.tar
gzip $1.tar

Quote:}

--

It's a damn poor mind that can only think of one way to spell a word.
        - Andrew Jackson
UIN=66618055
 
 
 

tar+gz in one shot

Post by those who know me have no need of my nam » Thu, 28 Mar 2002 03:53:13



Quote:>    I cannot implement a similar alias in bash to tar and
>gzip a directory in one command. Even a simple alias like
>alias tar='tar cvf- $1.tar $1'

an alias is the wrong way to do it, use a function instead:

targz () {

Quote:}

--
bringing you boring signatures for 17 years