Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to find function name based on word search Post 302334540 by spc432 on Thursday 16th of July 2009 02:09:49 AM
Old 07-16-2009
hi radoulov,

Ur code is giving syntax errors ...i couldnt rectify....
Code:
 
awk '/^public function/, /END public function/ { 
  /^public function/ && fn = $0
  if ($0 ~ sc) print fn
  }' sc='call Global Function1' infile

[/CODE]

Im getting following errors :

awk: syntax error near line 2
awk: illegal statement near line 2
awk: illegal statement near line 3

If possible please tell me how to fix above syntax errors for "awk" code

But i tried like this. Its working.....

Code:
 
cat infile|while read line
do
        echo $line |tr -d " "|grep "publicfunction"|grep -v END
        if [  $? -eq 0 ]
        then
                echo $line |read fname
        else
                echo $line |tr -d " "|grep "callGlobalFunction1"  
                if [  $? -eq 0 ]
                then
                        echo "--------" $fname
                fi
        fi
        echo $line |tr -d " "|grep "ENDpublicfunction"
        if [  $? -eq 0 ]
        then
                fname=
        fi
done



---------- Post updated at 11:39 AM ---------- Previous update was at 09:04 AM ----------

Hi all,

My file is about more than 20000 lines. My script is taking somuch time to get required ouput. Is it possible to do bit faster.........? My code attached already.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

search for hardlinks based on filename via find command

I am using command substitution into a find command in a script where I have built a menu to do a bunch of tasks within my unix account. When I choose the options for to find a file/files that have the same inode of the entered filename, ie hardlinks, nothing shows up. When I choose the appropiate... (2 Replies)
Discussion started by: hunternjb
2 Replies

2. UNIX for Dummies Questions & Answers

Using find command for timestamp based search

Hi, I am writing a script where i need to list all the files that have a scecific timestamp. I get this time stamp from another file. Is it possible to do this with 'find' command? Please let me know your valuable inputs. Thanks Sunny. (1 Reply)
Discussion started by: sunny_03
1 Replies

3. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

4. Shell Programming and Scripting

bash script to find date based on search string for continuesly updating file

Hi All, I am very new to UNIX and I have tried this for a longtime now and unable to crack it.... There is a file that is continuously updating. I need to search for the string and find the date @ which it updated every day..... eg: String is "work started" The log entry is as below: ... (1 Reply)
Discussion started by: Nithz
1 Replies

5. Shell Programming and Scripting

Find and copy files based on todays date and search for a particular string

Hi All, I am new to shell srcipting. Problem : I need to write a script which copy the log files from /prod/logs directory based on todays date like (Jul 17) and place it to /home/hzjnr0 directory and then search the copied logfiles for the string "@ending successfully on Thu Jul 17". If... (2 Replies)
Discussion started by: mail.chiranjit
2 Replies

6. Shell Programming and Scripting

Search for the word and exporting 35 characters after that word using shell script?

I have a file input.txt which have loads of weird characters, html tags and useful materials. I want to display 35 characters after the word description excluding weird characters like $$#$#@$#@***$# and without html tags in the new file output.txt. Help me. Thanx in advance. My final goal is to... (11 Replies)
Discussion started by: sachit adhikari
11 Replies

7. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

8. UNIX for Beginners Questions & Answers

Search for word in huge logfile and need to continue to print few lines from that line til find date

Guys i need an idea for one logic..in shell scripting am struggling with a logic...So the thing is... i need to search for a word in a huge log file and i need to continue to print few more lines from that line and the consecutive line has to end when it finds the line with date..because i know... (1 Reply)
Discussion started by: Prathi
1 Replies

9. Shell Programming and Scripting

Script to find string based on pattern and search for its corresponding rows in column

Experts, Need your support for this awk script. we have only one input file, all these column 1 and column 2 are in same file and have to do lookup for values in one file(column1 and column2) but output we need in another file Need to grep row whose string contains 9K from column 1. When found... (6 Replies)
Discussion started by: as7951
6 Replies

10. UNIX for Beginners Questions & Answers

How to search for a word in column header that fully matches the word not partially in awk?

I have a multicolumn text file with header in the first row like this The headers are stored in an array called . which contains I want to search for each elements of this array from that multicolumn text file. And I am using this awk approach for ii in ${hdr} do gawk -vcol="$ii" -F... (1 Reply)
Discussion started by: Atta
1 Replies
fsaparse(3gv)															     fsaparse(3gv)

NAME
fsaparse - parse a word-acceptor automaton file SYNOPSIS
#include "wa.h" fsafparse(fp, fsa) FILE *fp; Fsa *fsa; DESCRIPTION
fsafparse parses a word-acceptor automaton file in the format described by DEAGL ("Data Exchange for Automata and Groups Language") (but see the BUGS section below). fp should be a pointer to an open file containing the automaton. fsa should be a pointer to an Fsa struture as defined in "fsa.h". Upon return, the automaton will have been written into this structure. RETURN VALUES
On success, fsafparse() returns 1. On failure, it returns 0. SEE ALSO
getwordlist(3), getmatlist(3), fgetmatlist(3), getmatlist(1), automata(1) BUGS
fsafparse is meant specifically for use with getwordlist(3) and getmatlist(3). It does not recognize the full language described by DEAGL. It only recognizes that part of it which was present in the word-acceptor files that I was working with when I wrote it. I think this may be sufficient for all word-acceptor automata, but I am not sure of this. Please let me know if you find word-acceptor files for which this doesn't work. AUTHOR
Mark Phillips The Geometry Center Sat Mar 23 22:01:32 1991 fsaparse(3gv)
All times are GMT -4. The time now is 10:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy