perl の backtik オペレーター内で awk コマンドを実行したい。それは私にエラーを与えています。引用符、パイプをエスケープしようとしましたが、何も機能していないようです。
my @fieldCnt=`head -1 $inputFileDir/$cmdParams{mas}|awk -F, \'print NF\'`;
perl の backtik オペレーター内で awk コマンドを実行したい。それは私にエラーを与えています。引用符、パイプをエスケープしようとしましたが、何も機能していないようです。
my @fieldCnt=`head -1 $inputFileDir/$cmdParams{mas}|awk -F, \'print NF\'`;
awk を使用するのではなく、perl スクリプト内で実行します。あなたが達成しようとしていることを理解できれば、カンマで区切られた行の項目数を探しています。
# 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
うまくいけば、これは役に立ちます。