想要在perl中的backtik运算符内运行awk命令。这给了我一个错误。我试图逃避报价,管道,但似乎没有工作。在perl脚本中运行awk命令
my @fieldCnt=`head -1 $inputFileDir/$cmdParams{mas}|awk -F, \'print NF\'`;
想要在perl中的backtik运算符内运行awk命令。这给了我一个错误。我试图逃避报价,管道,但似乎没有工作。在perl脚本中运行awk命令
my @fieldCnt=`head -1 $inputFileDir/$cmdParams{mas}|awk -F, \'print NF\'`;
我只想做perl脚本中,而随后用awk。如果我理解你想达到什么样的,你正在寻找项目的用逗号分隔的行数,然后
# Open the file for reading
open my $fh,"$cmdParams{mas}" or die "Unable to open: $cmdParams{mas}";
my $firstLine = <$fh>; # Get the first line
close($fh); # close the file
my @items = split(',',$firstLine); # Get the items separated by comma's
$numberOfFields = scalar(@items); # Get the count of the number of items
希望这是有帮助的。
你为什么在Perl内运行awk? – TLP
awk命令中的花括号({}}在哪里? – Vijay
非常感谢您的信息。缺少大括号是问题 – Arav