Operating System - HP-UX
1753765 Members
5813 Online
108799 Solutions
New Discussion юеВ

Compress and move in one step.

 
Gulam Mohiuddin
Regular Advisor

Compress and move in one step.

How to move and compress several files in one step?

Sometimes manually I need to move some of Oracle archive log files to another directory on the fly due to lack of space.

I need a quick command to achieve this and may be cron it.

Thanks,

Gulam.
Everyday Learning.
6 REPLIES 6
David Burgess
Esteemed Contributor

Re: Compress and move in one step.

I can do it in 2, but it can go on one line in your cron.

/bin/compress a; /bin/mv a.Z /tmp/test

where /tmp/test is a directory.

Regards,

Dave.
Michael Schulte zur Sur
Honored Contributor

Re: Compress and move in one step.

Hi,

you can use
compress -c filetocompress > /path/to/dir/compressedfile
-c is output to stdout


greetings,

Michael
Patrick Wallek
Honored Contributor

Re: Compress and move in one step.

Another way:

# compress < filetocompress > /path/filetocompress.Z

If you want a script:

for FILE in $(cat listoffilestocompress)
do
echo "Compressing ${FILE}"
compress < ${FILE} > /path/${FILE}.Z
done
Gulam Mohiuddin
Regular Advisor

Re: Compress and move in one step.

I am trying to MOVE and Compress together in one step.

But the posted answers jut show how to compress but not how to move and compress as well.

Gulam.
Everyday Learning.
Michael Schulte zur Sur
Honored Contributor

Re: Compress and move in one step.

Gulam,
can you tell us, what the difference is between out approach and your's is?
Both in one step isn't possible.
I let the compress output it's compressed stram on stdout and put it there, where it is supposed to be. Then you can rm the orignal. If you think, you can spare a temporary file during compression, I think that is not possible.

Michael
RAC_1
Honored Contributor

Re: Compress and move in one step.

May be this is OK for you.

mv file /path/file && compress /path/file

Anil
There is no substitute to HARDWORK