0
这是我的代码Perl不评估bash脚本正确
my $shell_line_diff=`echo $(($(diff -U 0 ftest1.txt ftest2.txt|grep ^\+|wc -l)-$(diff -U 0 ftest1.txt ftest2.txt|grep ^\-|wc -l)))`;
print "difference in the number of lines is $shell_line_diff\n";
和评估脚本正常工作在Linux上的bash。
但在Perl它给了我下面的结果:
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `echo 1010 1010 10000000 10000003 10000004 10000010(1010 1010 10000000 10000003 10000004 10000010diff -U 0 ftest1.txt ftest2.txt|grep ^+|wc -l)-1010 1010 10000000 10000003 10000004 10000010diff -U 0 ftest1.txt ftest2.txt|grep ^-|wc -l)))'
difference in the number of lines is
我做了什么错?
你应该有两个开头的括号'('? – ShellFish
你正在推进很多工作,你可以在Perl中直接进行shell的工作。 – chepner