I wanted to compare the value inside the Squre bracket after Colon ( : ) based on any value(seperated by or operator | ) inside the variable Thread and if match found then wnated to store in output file
Input file :
20140320 00:08:43.918 INO [WebContainer : 35] - Corporate hub [indr] is
20140320 00:08:43.918 DEMO [testing : 125] - anyvalue lab lab
20140320 00:08:43.918 INFO [anydata : 5] - Remote Worker indr is
20140320 00:08:43.918 any [debug : 51] - Activity is: [Ljava.lang.]
20140320 00:08:43.918 dump [interprit : 125] - Activity from form is: [All]
20140320 00:08:43.918 WEB [Web : 21] - Activity Status from form is: [All]
20140320 00:08:43.918 THink [WebCont : 5] - anything
I tried with following code but not getting expected output. Need help on this.
INPUTFILE = "TEMP.TXT"
Outputfile = "Result.txt"
Thread = "35|5|125"
#grep -Po '(?<=\[).*?(?=\])' $INPUTFILE >> $Outputfile
grep -Po '(?<=\[)$Thread(?=\])' $INPUTFILE >> $Outputfile
Expected Output file : based on Thread = "35|5|125"
20140320 00:08:43.918 INO [WebContainer : 35] - Corporate hub [indr] is Y
20140320 00:08:43.918 DEMO [testing : 125] - anyvalue lab lab
20140320 00:08:43.918 INFO [anydata : 5] - Remote Worker indr is
20140320 00:08:43.918 dump [interprit : 125] - Activity from form is: [All]
20140320 00:08:43.918 THink [WebCont : 5] - anything
Thanks in advance