Hi,
I need to match lines after a pattern, upto the first blank line.
Searched in web and some forums but coulnt find the answer.
where <restart_step> =
10 -- Execute query
20 -- Write the contents to the Oracle table
30 -- Writing Contents to OUTPUT Directory
the number of steps may vary. I need to match the lines after <restart_step> .
Many Thanks
try this,
awk 'BEGIN{RS="\n\n";FS="<restart_step> ="} { print $2}' inputfile
1 Like
Hi pravin
The above code just displays 4 blank lines .
---------- Post updated at 01:39 AM ---------- Previous update was at 01:36 AM ----------
Pravin,
Thanks a ton! just changing to print$0 instead of $2 gives the desired output!
awk 'BEGIN{RS="\n\n";FS="<restart_step> ="} { print $0}'
It works fine at my end
# cat testfile
where <restart_step> =
10 -- Execute query
20 -- Write the contents to the Oracle table
30 -- Writing Contents to OUTPUT Directory
test
for you
#awk 'BEGIN{RS="\n\n";FS="<restart_step> ="} { print $2}' testfile
10 -- Execute query
20 -- Write the contents to the Oracle table
30 -- Writing Contents to OUTPUT Directory
Could you please post your input file.
Hii Pravin,
> cat file.txt
where <restart_step> =
10 -- Execute query
20 -- Write the contents to the Oracle table
30 -- Writing Contents to OUTPUT Directory
test
for you
> awk 'BEGIN{RS="\n\n";FS="<restart_step> ="} { print $2}' file.txt
>
Am sorry there ws a mistake. The same code gives different output..
is there any other way to achieve this
does this help..
sed '/<restart_step>/,/^$/!d' inputfile
1 Like
awk '!NF{p=0}p;/restart_step/{p=1}' infile
1 Like
@scrutinizer and michael
Thanks very much.. Both of them work fine!