is there a way to search for two words at the same time in different lines

9 views
Skip to first unread message

Spriya

unread,
Nov 24, 2014, 10:18:31 AM11/24/14
to puppet...@googlegroups.com
Hi All,

I have a text file which contains 
/u01/java/jdk1.7.0_72/jre/bin/java
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
/u01/java/jdk1.7.0_72/bin/java
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
/u01/java/jdk1.7.0_65/jre/bin/java
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

I am tryng to seach for a line which contains word java and as well as java_versions.

I mean  if i search only java i need to get 
/u01/java/jdk1.7.0_72/jre/bin/java
/u01/java/jdk1.7.0_72/bin/java
 and 
if search for word java version i need to get 
"1.7.0_72" 
"1.7.0_65"

Like this can i do it same time for searching

I tried this but it is not working

logfile = "/home/weblogic/javaapp.txt"
java_count = 0
if File.exist? '/home/weblogic/javaapp.txt'

log = Facter::Util::FileRead.read(logfile)
unless log.nil?
log.each_line do |line|
 if line.include?('/java') and line.include?('java version')

But it is not returning anything

Anyone please help me

Reply all
Reply to author
Forward
0 new messages