[Centos] help with xargs and mv

Tue Feb 8 20:15:49 UTC 2005
James B. Byrne <ByrneJB at Harte-Lyne.ca>

I am trying to move a group of sendmail queue files into a special 
area and am developing s script to assist.  The manual steps are:

# Identify which messages to move
mailq -qR<domain> > file1

# Select only lines with message ID strings
grep '^[[:alpha:]][[:alnum:]]\{13\}' file1 > file2

# extract only the messages ID
cut -b -14 file2 > file3

# prepend '*' to message IDs
sed "s/^/\*/" file3 > file4

All of this works the way that I expect.  What I now want to do is 
to mv all of the related files listed in file4 in the form 
"*messageid" to another directory.  Using xargs I expected 
(naively) that the following construction would work:

cat file4 | 	xargs mv /var/spool/mqueue/'{}' \
			/var/spool/mqueue/offline 

(note that in the original this is all one line.)

However, when I do this I get the error:
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.

There is obviously something about xargs that I do not understand.  
In my imagination I see this xargs construction expanding to this:

mv /var/spool/mqueue/*messageid1 /var/spool/mqueue/offline
mv /var/spool/mqueue/*messageid2 /var/spool/mqueue/offline
.
.
.
mv /var/spool/mqueue/*messageidn /var/spool/mqueue/offline

so that the qf and df files for each message are moved into the 
subdirectory offline.  But this is obviously incorrect.  Can anyone 
here point out to me what my misunderstanding is and how to get 
this to work?  If this is not the forum for this kind of question 
then can someone with more experience point me to a mailing list 
that would be more suitable?

Regards,
JIm

--   
     *** e-mail is not a secure channel ***
mailto:byrnejb.<token>@harte-lyne.ca
James B. Byrne                Harte & Lyne Limited
vox: +1 905 561 1241          9 Brockley Drive
fax: +1 905 561 0757          Hamilton, Ontario
<token> = hal                 Canada L8E 3C3