Move with compression

How can I move a file and compress it at the same time?

What do you mean move and compress ?

compress already replaces the file with the compressed one.

man compress says

       Compress  reduces the size of the named files using adaptive Lempel-Ziv
       coding.  Whenever possible, each file  is  replaced  by  one  with  the
       extension  .Z, while keeping the same ownership modes, access and modification times. 

Hi
I need to move a file from one location to a new location in a compressed format
I dont want to set up a compressed pipe running in the background to achive this. I was hone to do it in a single line but cant seem to work it out

ie mv foo /dir/foo.Z |compress or something like that ???

Simplest I can think of is

compress file && mv file.Z /destination/dir

Thanks that works
is there a way to compress during the move by redirecting the file through compress or something like that ?

What do the two && do?

I believe you are asking for this feature - compress the file and save it into another location.
It wouldnt be there. Because, the man page says the original file is replaced. So, the destination directory will be the same as the source directory.

The idea of && is the same as the AND operator.
From man sh

       The  control operators && and || denote AND lists and OR lists, respec-
       tively.  An AND list has the form

              command1 && command2

       command2 is executed if, and only if, command1 returns an  exit  status
       of zero.

Thanks that helps

how abt gzip?

gzip < orig_file > orig_file.gz

Or if you really want to use compress, just use -c and then redirect to a file.... you're still left with the original so it's not actually "moving" the file.

$ compress -c svm_1.log > /var/tmp/svm_1.log.Z
$ file /var/tmp/svm_1.log.Z
/var/tmp/svm_1.log.Z:   compressed data block compressed 16 bits
$ uncompress -c /var/tmp/svm_1.log.Z > /tmp/uncompressed_log
$ file /tmp/uncompressed_log
/tmp/uncompressed_log:  ascii text

Cheers
ZB