I am reading a cpp file thru shell script . There are many fuctions inside the cpp file
eg
pvvd_fncn_name1
{
..... something
}
pvvd_fncn_name2
{
..... something
}
what I require is a method to find the first opening brace and the coresponding last brace and search for a pattern in that part between braces ...
Pls help
Thanks and Regards
sai21
2
You can do the following way...
- Intially you can set the counter varaible to 0
- Whenevr you find a open brace increment the counter and store line number in a variable
- When you find Close braces decrement the counter and then check the value of counter.
- If the counter is zero, the print the strings in between starting line number and the closed braces (i.e count =0) and store it in a file.
- Then search pattern in the stored file.
any help appreciated ..I am new to scripting .. I also thought something like that only but couldnt implement it technically