问题描述
我有以下脚本,我需要将变量$ f用双引号括起来,因为某些文件中有空格:
# create a reftime (for the last 24 hours)
((reftime=$(date '+%s')-(24*60*60)))
# create a reffile for that time in /var/tmp (or any other place)
reffile=/var/tmp/reffile.$$.tmp
touch --date=@${reftime} ${reffile}
# find all files (in srcbase),that was changed in the last 24h - that means
# Now all files that are newer then our reffile,and copy to destbase...
srcbase=/myorigin
dest=gpadmin@10.0.1.8:/mydest/dest
# for all of these files we need the directory names (because we need the structure for copy)
chgfiles=/var/tmp/chgfile.$$.tmp
find ${srcbase} -type f -newer $reffile 2>/dev/null | sort -u >${chgfiles}
cat ${chgfiles} | while read f ; do
# echo "copy file $f to destination $dest ..."
# create directory structures if not exist
#mkdir -p "${dest}"
# and finaly cp the file
scp "$f" $dest
done
# clear all tmp files
rm ${reffile} ${chgfiles}
我尝试了scp "$f" $dest
,但是没有用。.
有什么想法吗?
谢谢!
解决方法
这有效:
scp "${f}" $dest
它在我需要的文件周围添加了双引号。
我想我错过了{}