Sponsored Content
Top Forums Shell Programming and Scripting Help in retrieving the ending line numbers of the functions Post 302529648 by abk07 on Friday 10th of June 2011 02:21:19 AM
Old 06-10-2011
Bug Help in retrieving the ending line numbers of the functions

Hi! I've a C file which consist of many function definitions with numbers at the beginning as shown below..

Code:
10 void search()
11 {
12 /*body
14 *
15 *
17 *
18 *
40 *
42 *
60 }
90 void func_name()
95 {
99 /*body
100 *
105 *
111 *
112 *
130 *
135 }

I need to retrive the number at which the function begins and ends..
I mean the function 'search' begins at number 10 and ends at number 60.
In the same way the function 'fun_name()' begins at number 90 and ends at 135..
I can somehow get the beginning line number of the functions using grep..
But how can I get the ending line number??
Note: The numbers used will not be in the order, and there might be many opening and closing braces in the functions..

How can I do it??
Thanks in advance.. Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending line ending with '}" to new line

Hello masters. I have a rather simple problem but its been killing me. I have a file "x" with only 1 line inside it. The line looks something like Now this is only part of the line. Its actually about 4000 characters. What i need to do is whenever there is a "}", i need to append the next... (4 Replies)
Discussion started by: aismann
4 Replies

2. UNIX for Advanced & Expert Users

Retrieving command line arguments of a particular PID

hi The "ps" command shows the command line arguments of running processes: $ /bin/ps -o pid,args -e .... 26031 pico /tmp/crontab2KaG1Y 596 /usr/lib/sendmail -bd -q15m 9955 xterm -n 1 -sb -sl 800 -g 80+70+70 2627 /usr/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd -a 1691 .... I... (2 Replies)
Discussion started by: Andrewkl
2 Replies

3. UNIX for Dummies Questions & Answers

Retrieving random numbers out of a text file

Hi one and all, I'm working on a Bash script that is designed to calculate how much IP traffic has passed through a port to determine traffic volume over a given amount of time. I've currently been able to use the netstat -s command coupled with grep to write to a file the total packets... (13 Replies)
Discussion started by: nistleloy
13 Replies

4. Shell Programming and Scripting

Retrieving data from 65th col (of each line) ?

Hello Friends, I am in situation where I have to note down few SQL queries from specific hexdump format. Here is an example (the query text starts at 65th character on each line) ---------------------- 0x000007FEB0E701C0 : 7365 6C65 6374 2063 7573 746E 6F2C 2020 select custno, ... (9 Replies)
Discussion started by: Sunusernewbie
9 Replies

5. Shell Programming and Scripting

Retrieving values from a line in text file

Hi, I am new to Unix/ksh script and will like to check how do I retrieve just the count of '258' in the last line in a text file ? There will be this "TRL" appended with number of count at the last line in a text file . TRL0000000258 var=`grep 'TRL' $HOME/folder/test.txt | wc -l` ... (12 Replies)
Discussion started by: snowfrost
12 Replies

6. Shell Programming and Scripting

Retrieving line number from grep

Hi. im trying to retrieve the line number from grep. i have 1 part of my code here. grep -n $tgt file.txt | cut -f 1 -d ":" when i do not cut the value i have is 12:aaa:abc:aaa:aaa:aaa how can i store the value of 12 or my whole line of string into a variable with grep? (6 Replies)
Discussion started by: One_2_three
6 Replies

7. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

8. UNIX for Dummies Questions & Answers

Sorting files ending in numbers with "sort"

I have a group of files that I need to be sorted by number. I have tried to use the sort command without any luck. ls includes* includes1 includes10 includes11 includes12 includes2 includes3 includes4 includes5 includes6 includes7 includes8 includes9 I have tried ls includes*... (6 Replies)
Discussion started by: newbie2010
6 Replies

9. UNIX for Advanced & Expert Users

Pring starting and ending numbers using UNIX

Hi all, I need to do scrip for printing starting and ending numbers along with count in given file.:wall: Input: a.txt 10000030 10000029 10000028 10000027 10000026 10000024 10000023 10000021 10000018 10000018 10000017 10000016 10000015 10000014 (2 Replies)
Discussion started by: jackbell2013
2 Replies

10. Shell Programming and Scripting

Remove '.' from file for numbers ending in '.'

Hi, I have numerous files which have data in the following format A|B|123.|Mr.|45.66|33|zz L|16.|33.45|AC.|45. I want to remove decimal point only if it is last character in a number. O/p should be A|B|123|Mr.|45.66|33|zz L|16|33.45|AC.|45 I tried this sed -e 's/.|/|/g' Problem... (6 Replies)
Discussion started by: wahi80
6 Replies
TextBuffer(3I)						    InterViews Reference Manual 					    TextBuffer(3I)

NAME
TextBuffer - operations on unstructured text SYNOPSIS
#include <InterViews/textbuffer.h> DESCRIPTION
TextBuffer defines common editing, searching, and text movement operations on a buffer of unstructured text. Text positions are specified by an index into the buffer and logically refer to positions between characters. For example, the position referred to by the index 0 is before the first character in the text. Indices can be compared for equality or ordering, but they should not be used to directly access the buffer because TextBuffer might rearrange the text to improve the efficiency of some operations. PUBLIC OPERATIONS
TextBuffer(char* buffer, int length, int size) ~TextBuffer() Create or destroy an instance of TextBuffer. All operations on the text contained in buffer should be performed through TextBuffer functions. The text is assumed to be of length length, and the total available buffer size is size. int Search(Regexp* regexp, int index, int range, int stop) int ForwardSearch(Regexp* regexp, int index) int BackwardSearch(Regexp* regexp, int index) Search for a match with the regular expression regexp, beginning at position index. Search searches the part of the buffer speci- fied by range and stop and returns the index of the beginning of the matched text. Positive values of range specify forward searches, and negative values specify backward searches. In either case, the matched text will not extend beyond the position given by stop. ForwardSearch searches for matches from index to the end of the text and returns the index of the end of the match. Back- wardSearch searches from index to the start of the text and returns the index of the beginning of the match. All three functions return a negative number if there was no match. int Match(Regexp* regexp, int index, int stop) boolean ForwardMatch(Regexp* regexp, int index) boolean BackwardMatch(Regexp* regexp, int index) Attempt to match the regular expression regexp at the position index. Match returns the length of the matching string, or a nega- tive number if there was no match. Matching will not succeed beyond the position given by stop. ForwardMatch looks for a match that begins at index. BackwardMatch looks for a match that ends at index. int Insert(int index, const char* string, int count) int Delete(int index, int count) int Copy(int index, char* buffer, int count) Edit the text in the buffer. Insert inserts count characters from string at the position index. It returns the actual number of characters inserted, which might be less than count if there is insufficient space in the buffer. Delete deletes count characters from the buffer. A positive count deletes characters after index, and a negative value deletes character before index. Delete returns the actual number of characters deleted, which might be less than count if index is near the beginning or the end of the text. Copy copies count characters into buffer. A positive count copies characters after index and a negative count copies charac- ters before index. Count returns the actual number of characters copied. It is the caller's responsibility to ensure that buffer contains sufficient space for the copied text. int Height() int Width() int Length() Return information about the text. Height returns the number of lines in the text, Width returns the number of characters in the longest line, and Length returns the total number of characters. const char* Text() const char* Text(int index) const char* Text(int index1, int index2) char Char (int index) Access the contents of the text. Char returns the character immediately following index. The three Text calls return pointers to character strings representing the text. They make various guarantees about the format of the returned string. With no parameters, Text returns a pointer to a string that contains the entire text of the buffer. With a single parameter the string contains at least the text from index to the end of the line. With two parameters, the returned string contains at least the text between index1 and index2. In any case, the returned string should be considered temporary and its contents subject to change. To maximize efficiency, you should prefer the more restricted forms of Text. int LineIndex(int line) int LinesBetween(int index1, int index2) int LineNumber(int index) int LineOffset (int index) Map between text indices and line and offset positions. LineIndex returns the index of the beginning of line line. LineNumber returns the number of the line that contains index. LineOffset returns the offset of index from the beginning of its containing line. LinesBetween returns the difference between the numbers of the lines containings index1 and index2; a return value of zero indicates that index1 and index2 are on the same line, and a positive value indicates that the line containing index2 is after the line containing index1. Lines are numbered starting from zero. int PreviousCharacter(int index) int NextCharacter(int index) Return the index immediately following or preceding index. The returned value is never before the beginning or after the end of the text. boolean IsBeginningOfText(int index) int BeginningOfText() boolean IsEndOfText(int index) int EndOfText() Return the index of the beginning or end of the text, or query whether index is at the beginning or end of the text. boolean IsBeginningOfLine(int index) int BeginningOfLine(int index) int BeginningOfNextLine(int index) boolean IsEndOfLine(int index) int EndOfLine(int index) int EndOfPreviousLine(int index) Return information about the line structure of the text around index. BeginningOfLine returns the index of the beginning of the line containing index. BeginningOfNextLine returns the index of the beginning of the next line that begins after index. EndOfLine returns the index of the end of the line containing index. EndOfPreviousLine returns the index of the end of the last line that ends before index. The beginning of a line is logically immediately after a newline character, and the end of a line is logically immediately before a newline character. The beginning and end of the text are considered to be the beginning and end of the first and last lines, respectively. boolean IsBeginningOfWord(int index) int BeginningOfWord(int index) int BeginningOfNextWord(int index) boolean IsEndOfWord(int index) int EndOfWord(int index) int EndOfPreviousWord(int index) Return information about the word structure of the text around index. BeginningOfWord returns the index of the beginning of the word containing index. BeginningOfNextWord return the index of the beginning of the nest word that begins after index. EndOfWord returns the index of the end of the word that contains index. EndOfPreviousWord returns the index of the end of the last word that ends before index. A word is defined as a sequence of alpha-numeric characters. The beginning and end of the text are considered to be the beginning and end of the first and last words, respectively. SEE ALSO
Regexp(3I) InterViews 23 May 1989 TextBuffer(3I)
All times are GMT -4. The time now is 05:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy