我在搜索值并打印时遇到问题。这就是我到目前为止所拥有的。我究竟做错了什么?如何通过搜索输出获得所需的输出?
my $host = $ARGV[0];
my $port = $ARGV[1];
my $domain = $ARGV[2];
my $bean = $ARGV[3];
my $get = $ARGV[4];
open(FILE, ">", "/home/hey");
print FILE "open $host:$port\n";
print FILE "domain $domain\n";
print FILE "bean $bean\n";
print FILE "get -s $get\n";
print FILE "close\n";
close FILE;
open JMX, "/root/jdk1.6.0_37/bin/java -jar /var/scripts/jmxterm-1.0-alpha-4-uber.jar -v silent -n < /home//hey |";
open (dbg, ">", "/home/donejava1");
#print JMX "help \n";
foreach ( <JMX> )
{
chomp;
print $_;
open (LOG, ">", "/home/out1");
print LOG $_;
close LOG;
}
//输出
{
committed = 313733;
init = 3221225472;
max = 3137339392;
used = 1796598680;
}
//如何打印1796598680,寻找属性“used”?
答案 0 :(得分:2)
以下示例应为您提供解决方案。
perl -lne'print $1 if /used\s*=\s*(\d+);/' filename