需要一些帮助 这就是我所拥有和想做的事情 这是我的文件,名为file.txt
Sequences times Ip1 ip2 Protocol info
1 2 10.18.19.12 12.29.29.18 udp hsahdsdd
2 4 10.13.15.67 12.28.29.19 tcp blabla
3 7 10.12.27.28 12.17.281.19 udp hkkkljkl
我想(使用Awk)
由于 我在这里尝试
#!/usr/bin/perl
$fname = $ARGV[0];
open(FILE, $fname) || die ("cant read \n");
while($ligne=<FILE>)
{
chop ($ligne);
my ($No, $time, $Ip1, $Ip2, $Proto, $info) = split (/ /, $ligne_);
}
system("awk '{print \$6}' $fname");
system ("awk 'END {print NR}' $fname") >line.txt;
答案 0 :(得分:3)
system
的那种形式采用shell命令,所以
use autodie qw( system );
use String::ShellQuote qw( shell_quote );
system(shell_quote('awk', 'END {print NR}', $fname) . ">line.txt");
但是在Perl中使用awk
来完成这项琐碎的工作是很愚蠢的。