combining mv and compress command

Hi All,

I have a file in DirA/ABC.out a need to move to DirB.I am using the following steps now:

mv DirA/ABC.out DirB
compress -f DirB/ABC.out

Is there a way to just do this one step as I have to move hundreds of files every hour.

-Thanks in advance.

A possible solution is to create a script (mvc for example):

#!/usr/bin/sh

if [ $# -ne 1 ]
then
   echo "Usage: $0 file" >&2
   exit 1
fi

mv DirA/$1 DirB/ && compress -f DirB/$1

To move and compress the file ABC.out:

mvc ABC.out

Jean-Pierre.

Thanks..
Works great.

Jean-Pierre,

In your actually command, why are you using $0 and not $1? Wouldn't $1 take the command line name of the file (ABC.out) and move it? It seems like your mv command would be attempting to move the script.

You consistently provide great answers, so I'm sure it's something simple I'm overlooking... I was just curious.

You are right, $1 must be used instead of $0 :o

Jean-Pierre.