Please help me in this issue.
I am unable to get the job,seems the awk not browsing the files.
Please find my tries below.
I have attached two files :
1.tobesearched.txt - a glimpse of a huge log file.
2.searchstring.txt - searching keys.
these are the two scripts i tried writing:
This is the shell script:
#!/bin/ksh
file="/new_var_app/temp/restoredlogs/cclogger/modified_RRN"
while read line
do
awk -f abc.awk cclogger.Z.2011-11-30_00:00:01 $line
done <$file
[SIZE=2][FONT=Helv]This is the awk script abc.awk:
#!/bin/awk -f
BEGIN {
{flag=1}
{
newstring=sprintf("%s %s %s %s %s %s %s %s %s %s %s %s",ARGV[2],ARGV[3],ARGV[4],ARGV[5],ARGV[6],ARGV[7],ARGV[8],ARGV[9],ARGV[10],ARGV[11],ARGV[12],ARGV[13])
print "Arg1--->"ARGV[1]
print newstring
if($0 ~ /$newstring/)
{flag=0}
if(flag == 0)
{ print $0 }
if ($0 ~ /dumpMsg/)
{
if (flag == 0)
{
flag=1
}
}
}
}
Here I am trying to take the searchstrings from the file searchstring.txt
and trying to search in the big log file.
My objective is : if i find a match,I have to paste the pattern
The pattern should
start with the line containing the search string.
it ends when it finds the keyword "dumpMsg".
fgrep -f searchstring.txt tobesearched.txt | grep "dumpMsg$"
Hi tkam,
It is not giving the desired output.
Let me explain what I want :
Suppose this is the logfile:
This is George
He is a good guy
He loves burger
End
I love Britain
This is Raz
He is a Bad guy
He drinks a lot
End
I love Nederlands
This is Tommy
He is a singer
He cooks pasta
End
I love Mexico
The file with search strings are:
George
Tommy
The output should be like this:
This is George
He is a good guy
He loves burger
End
This is Tommy
He is a singer
He cooks pasta
End
$ while read pattern; do perl -lane "print if /$pattern/ .. /End/" file.txt; done < search.txt
This is George
He is a good guy
He loves burger
End
This is Tommy
He is a singer
He cooks pasta
End
Hi tkamraj,
[host:Server]{testapp}/new_var_app/netx=>abc.sh > output.txt
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = (unset),
LC__FASTMSG = "true",
LANG = "En_US"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Getting the below error.
Output is written only for the first search string ...
There are 400+ search string.
show your original file and the search string file
---------- Post updated at 12:46 PM ---------- Previous update was at 12:45 PM ----------
also, post the command, which u tried
Hi tkamaraj,
Find the attached screenshots for the two files..
The log file is very big with repeating patterns.
the command i gave :
while read pattern; do perl -lane "print if /$pattern/ .. /dumpMsg/" cclogger.Z.2011-11-30_00:00:01; done < modified_RRN
Please see the attched two screenshots and my last query.
Thanks in advance.