Operating System - HP-UX
1753596 Members
6459 Online
108796 Solutions
New Discussion

Re: gzip, relocate and remove in 1!

 
SOLVED
Go to solution
EU-Admins-UNIX
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
Patrick Wallek
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.

EU-Admins-UNIX
Regular Advisor

Re: gzip, relocate and remove in 1!

Neither can I.

 

Thanks Patrick.

 

 

Tariq