我在 perl 文件中有以下代码。此命令的目的是在 file.txt.system(\' find . -type f -name file.txt | xargs sed -i -e \'$ ... 的末尾添加一行 \'- - test 0\'
我在 perl 文件中有以下代码。此命令的目的是在 file.txt 末尾添加一行 \'- - test 0\'。
system(" find . -type f -name file.txt | xargs sed -i -e "$ a- - test 0" ");
当我尝试运行脚本时,出现如下所示的错误。
Scalar found where operator expected at timeStampConfig.pl line 24, near "" find . -type f -name file.txt | xargs sed -i -e "$ a"
(Missing operator before $ a?)
Number found where operator expected at timeStampConfig.pl line 24, near "test 0"
(Do you need to predeclare test?)
String found where operator expected at timeStampConfig.pl line 24, near "0" ""
(Missing operator before " "?)
syntax error at timeStampConfig.pl line 24, near "" find . -type f -name file.txt | xargs sed -i -e "$ a"
Execution of timeStampConfig.pl aborted due to compilation errors.
我尝试从命令提示符执行下面的行并且运行良好。
find . -type f -name file.txt | xargs sed -i -e '$ a- - test 0'
我也尝试使用单引号,如下所示,但最终出现错误。
system("find . -type f -name file.txt | xargs sed -i -e '$ a- - test 0'");
sed: -e expression #1, char 1: unknown command: `-'
我是 perl 新手,需要一些帮助。