Hi Unix Gurus,
I have two part of question. Any one or both answers will help me a lot.
I have a folder with many files in them. They contain SQL statement , Bind variables, Timing etc. I want to find a particular SQL(stored in one file with multiple line). I want to find that SQL in all other log files and from those file , once SQL is find then print all lines below the SQL till we find text "SQL Statement Initial Fetch Time"(including this line). Greatly appreciate your help.
to reiterate
1. store sql in file (say a.sql). Find this sql in all *.log files in folder.
2. once sql find then in that file print lines below that sql till we reach string "SQL Statement Initial Fetch Time"
The actual SQL statement could be 100 line longer but I'll prepare smaller sample file.
say input sql file a.sql is as below
I have lot of log files with various sql in them. They may contains above 6lines (say one of following log b.sql has).
so output should be(from file b)
There may be c.log, d.log file in same folder. But may not contain above SQL statement so no output from them , but let's say e.log has same sql and few lines then out may need to add
Basically , I'll get few line below sql statement from each file. containg the sql statement challenge I have is
1. How to match full sql string(e.g above a.sql has 6 line total between select to . How to match this multiple line in all files in folder.
2. once above step 1 is found then how to get all line between sql ending( till word Fetch time comes up from each file.
Thanks
Moderator's Comments:
Code tags for code, please.
---------- Post updated 07-12-12 at 03:16 AM ---------- Previous update was 07-11-12 at 01:44 PM ----------
Hi,
if any one can help with either point 1 or 2 or both then it will be a great help.
Thanks
Ranjit
Last edited by Corona688; 07-11-2012 at 03:01 PM..
who have > in the second line remove this and run
if still getting problem then send more sample data as i have tested this with data you have provided
Hello
I am trying to write sed code where it will look through the text for lines with specific expression "Started by user" and when found, will also add the following line, and also lines with another expression "Finished:"
sed -n '/Started by user/, +1p, /Finished:/'... (4 Replies)
Hi Guys,
I am trying to format my csv file. When I spool the file using sqlplus the single row output is wrapped on three lines.
Somehow I managed to format that file and finally i am trying to make the multiple line on single line.
The below command is working fine but I need to pass the... (3 Replies)
Hi,
I have multiple files in my log folder. e.g:
a_m1.log
b_1.log
c_1.log
d_1.log
b_2.log
c_2.log
d_2.log
e_m1.log
a_m2.log
e_m2.log
I need to keep latest 10 instances of each file.
I can write multiple find commands but looking if it is possible in one line.
m file are monthly... (4 Replies)
I have a file
# cat /tmp/user_find.txt
/home/user/bad_link1
/home/user/www
/home/user/mail
/home/user/access_logs
/home/user/bad_link2
I need to delete lines where there are patterns /home/user/www, /home/user/mail and /home/user/access_logs. I used below method, but its throwing error... (8 Replies)
Hi everybody,
Fairly simple question here:
I need an awk, sed, or grep command that will find the same string multiple times on one line
needs to return all lines which contain .02 twice.
I do know the exact number of characters in between the two occurrences of .02 if that helps, all... (7 Replies)
I would perfer to use cut and paste to do this but I can't find a GUI to do this with. What I want to do is to find a multiple line block of code like
Exit Sub
Log_Handler:
then replace it with
GoTo RSLogRtn
Exit Sub
Log_Handler:
Basically it is just an insert, but I may want to... (8 Replies)
Hi all,
I want to display line number for matching string in a file. can anyone please help me.
I used
grep -n "ABC" file
so it displays
6 ABC.
But i only want to have line number,i don't want that it should prefix matching context with line number.
Actually my original... (10 Replies)
trying to use sed in finding a matching pattern in a file then deleting
the next line only .. pattern --> <ad-content>
I tried this but it results are not what I wish
sed '/<ad-content>/{N;d;}' akv.xml > akv5.xml
ex,
<Celebrant2First>Mickey</Celebrant2First>
<ad-content>
Minnie... (2 Replies)
I want to use find to locate files with two different extensions, and run a grep on the results. The closest I have gotten is incredibly slow and ugly:
for i in `ls -laR|egrep -e '(.js|.css)'`; do find . -name $i -print|xargs grep -H searchBg; done;
This method makes my eyes bleed. Help! ;)
... (2 Replies)
Hi,
I am stuck with pattern matching.
I need to match a particular pattern several times in a same line and replace them.
for ex.,
I need to convert
(abc XY) (bvf ZY) bla bla
to
XY ZY bla bla
I tried..
s/\(+ (.+)\)/$1/gi
and it works (2 Replies)