Finding opening and closing braces


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding opening and closing braces
# 1  
Old 03-08-2009
Bug Finding opening and closing braces

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
# 2  
Old 03-08-2009
You can do the following way...
1. Intially you can set the counter varaible to 0
2. Whenevr you find a open brace increment the counter and store line number in a variable
3. When you find Close braces decrement the counter and then check the value of counter.
4. 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.
5. Then search pattern in the stored file.
# 3  
Old 03-09-2009
Bug

any help appreciated ..I am new to scripting .. I also thought something like that only but couldnt implement it technically
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Curly braces in sed

Hi, I have below command in one of the script. Can you please let me know what does the curly braces do over here \{1,\}. The remaining part of the code atleast I am able to understand. sed -n 's/.*\-\()\{1,\}\)\-.*/\1/p' (13 Replies)
Discussion started by: tostay2003
13 Replies

2. Shell Programming and Scripting

For getting value between the braces

Hi I have a file called tmp with the content as belowmore tmp NAMELIST(Hari) NAMELIST(Raju) I want to get the values between the brackets. When I executed the below command on zlinux I get the output which I wantedmore tmp |awk -F'' '{print $2}' But when I execute the same in... (3 Replies)
Discussion started by: harimhkr
3 Replies

3. Shell Programming and Scripting

Help with Shell Script opening and closing a program

REALLY new to this stuff, sorry. So I want a shell script to open a program, wait 45 minutes, close it, and then do it all again. I want to do this because I am running an iMacros Script for a long period of time and if Firefox is not constantly restarted, memory leaks start to happen. Anyway... (6 Replies)
Discussion started by: plsbbg
6 Replies

4. Shell Programming and Scripting

TCL - Question regarding Braces {}

Hello everyone, What is the difference between these two tcl commands: (A) --> puts "ERROR!!! ${current_name}/${opt} is not found." (B) --> puts "ERROR!!! $current_name/$opt is not found." Are the braces needed to be put? Or both A and B has the same output? (5 Replies)
Discussion started by: mar85
5 Replies

5. Shell Programming and Scripting

Finding max number in filename and opening it

Hi, I have files named as energy.dat.1 energy.dat.2 energy.dat.3 ... energy.dat.2342 I would like to find the file with maximum number in the filename (ex. energy.dat.2342) and open it. Would you please share your expertize in writing the script? Thanks in advance. (8 Replies)
Discussion started by: rpd25
8 Replies

6. OS X (Apple)

Opening and Closing Shares via ssh

Might anyone have an idea on how to mount an xserve share via ssh, then close the share connection? (3 Replies)
Discussion started by: unimachead
3 Replies

7. Shell Programming and Scripting

grep matter between braces

#include<header.h> void classname :: pvvd_init ( abcd ,efgh ,ijkl ,mnop ) { rvcl_tabl_name_tabl.pvvd_init ( xxxx ,"tabl_mame" ) ; ... (2 Replies)
Discussion started by: ultimatix
2 Replies

8. Shell Programming and Scripting

Finding the line number of matching braces

Hi,I am new to shell scripting and i want to find the line numbers of matching braces. The file contents are as follows File XXX.dat 1 ( CLASS "FRUIT" 2 (TYPE "PERSISTENT") 3 (MESSAGE_TYPE "M") 4 (GET_REQRD "Y") 5 (SET_REQRD "Y") 6 ) 7 ( CLASS... (3 Replies)
Discussion started by: Rajendra_1510
3 Replies

9. Post Here to Contact Site Administrators and Moderators

Opening and closing threads

Hi all, Just thought I'd mention something I've noticed since joining this forum :) Would it be a good idea to close threads once the initial question that was posted has been answered? I notice a few posts where people go on and on and as soon as you post a reply to one question they... (2 Replies)
Discussion started by: _Spare_Ribs_
2 Replies

10. Post Here to Contact Site Administrators and Moderators

Requests for Opening/Closing Threads

Please send an email to the administrator(s) of the board with thead ID and forum for any thread that is closed that you want open (or open that you want closed). All requested considered. Our apologies if sometimes threads are closed early. If this happens, please email :) Nobody is perfect... (0 Replies)
Discussion started by: Neo
0 Replies
Login or Register to Ask a Question