【发布时间】:2015-10-03 23:33:22
【问题描述】:
这是代码:
#!/usr/bin/perl -w
$dir="/vol.nas/rpas_qc/mohima/Test/translations";
$dir1="/vol.nas/rpas_qc/mohima/Test/dest";
`find $dir -type f -exec rsync -a {} $dir1\`;
这一行:
find $dir -type f -exec rsync -a {} $dir1\
在 Unix 中运行良好,但在 perl 中出现错误:
Can't find string terminator "`" anywhere before EOF at test1.pl line 4
我正在尝试将 $dir 中的所有文件复制到 $dir1 而不包含子目录。
使用 perl,因为脚本会做很多其他在 perl 中更容易的事情。
任何帮助表示赞赏。
【问题讨论】:
-
尝试在末尾使用双反斜杠 \\ 而不是单反斜杠 \。
-
反斜杠用于转义字符。在这种情况下,它会转义反斜杠。如果你想在 $dir1 后面加一个反斜杠,你需要把 to in 来转义反斜杠。所以你需要有 $dir\\ 而不是 $dir\。
-
find $dir -type f -exec rsync -a {} $dir1\“在 Unix 中”不能正常工作。\后跟换行表示命令在下一行继续。