Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: gzip, relocate and remove in 1!

 
SOLVED
Go to solution
Highlighted
Regular Advisor

gzip, relocate and remove in 1!

Hi

 

Is it possible to gzip and relocate the compressed file and remove the original uncompressed file in one command?

 

I know if you gzip in the same location, the .gz file replaces the original file, and that if you use the -c and the >, both files remain.

 

Regards

 

Tariq

2 REPLIES 2
Highlighted
Honored Contributor
Solution

Re: gzip, relocate and remove in 1!

The closest you are going to be able to get is something like this:

 

# gzip -c afile > afile.gz && rm -f afile

 

The '&& rm -f afile' will remove the file afile IF the gzip command succeeds.

 

There is nothing native in gzip, that I can find, that will do what you want to do.

Regular Advisor

Re: gzip, relocate and remove in 1!

Neither can I.

 

Thanks Patrick.

 

 

Tariq