Since my nfs
is a win
type of server, it can't contain :
. I want to copy multiple files from source server to the nfs
directory on another server and rename them at the same time.
The script looks like:
#!/bin/bash
in_files="node1:~/experiment/wrfout_d01_2012-12-01*"
###########################################################
# the files look like wrfout_d01_2012-12-01_00:00:00
# wrfout_d01_2012-12-01_06:00:00
# wrfout_d01_2012-12-01_12:00:00
# wrfout_d01_2012-12-01_18:00:00
###################################
for fn in $in_files;do
echo $fn
newfn=$(basename "$fn")
echo 'apply basename :'
echo $newfn
scp -r "$fn" "./${newfn//:/_}"
echo 'next:'
done
After run this script, it reports
node1:~/experiment/wrfout_d01_2012-12-01*
apply basename :
wrfout_d01_2012-12-01_12_00_00
./wrfout_d01_2012-12-01*: File name too long
./wrfout_d01_2012-12-01*: File name too long
./wrfout_d01_2012-12-01*: File name too long
./wrfout_d01_2012-12-01*: File name too long
next:
But it seems that if I apply the script to only one file, it is OK,(i.e. change the in_files
to a certain file),for example:
node1:~/experiment/wrfout_d01_2012-12-01_00:00:00
apply basename :
wrfout_d01_2012-12-01_00:00:00
wrfout_d01_2012-12-01_00:00:00 100% 71MB 70.5MB/s 00:00
next:
1.So how should I do to let it work for multiple files?
2.By the way it seems rsync
can also do this part, which one is faster or preferred.