The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ksh functions scriptingmani Shell Programming and Scripting 3 07-06-2007 04:15 AM
finding duplicate files by size and finding pattern matching and its count jerome Sukumar Shell Programming and Scripting 2 12-01-2006 01:20 AM
functions in Raom Shell Programming and Scripting 6 07-21-2006 12:06 AM
Regarding functions sendhilmani Shell Programming and Scripting 2 03-24-2006 01:40 AM
FTP functions hzambra High Level Programming 3 05-03-2002 10:06 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-16-2003
Registered User
 

Join Date: Dec 2003
Location: Fairfax, VA
Posts: 7
finding functions

I'm working on a project right now and I'm supposed to figure out how to go into a file located in a directory called ~cs252/Assingment/commandAsst/project/ and find all of the function calls to "sequentialInsert" and I tried using

grep "\<sequentialInsert\>"~cs252/Assingment/commandAsst/project/

and that didn't work...so I'm a little stuck right now...Could anyone point me in the right direction? Am I supposed to use some wildcards in place of sequentialInsert?
Forum Sponsor
  #2  
Old 12-16-2003
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
adamsy Try simply:
find /cs252/Assingment/commandAsst/project/ -exec grep -l 'sequentialInsert'{} \;

Search the directory and list the name of all files matching the string 'sequentialInsert'. Note that you can shorten the path in the find statement. This will cause find to search down the directory tree.
see man find and man grep

Add some grep switches to suit your needs. A few examples:
Ignore case (-i)
Display the line number (-n) of the file where the match occured.
Display the name (-l) of the file where the match occured.

Last edited by google; 12-17-2003 at 08:37 AM.
  #3  
Old 12-18-2003
Registered User
 

Join Date: Dec 2003
Location: Fairfax, VA
Posts: 7
Hey, I tried that command that you posted for me and I got two error messages. "find: incomplete statement" and "sequentialInsert;: Command not found". Do you know what I'm doing wrong here? Thanks for the help.
  #4  
Old 12-18-2003
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
Code:
find /cs252/Assingment/commandAsst/project/ -exec grep -l 'sequentialInsert'{} \;
it all goes on 1 line. i can only assume you put it on 2 lines.
  #5  
Old 12-18-2003
kduffin's Avatar
UN1X
 

Join Date: Nov 2003
Location: Virginia
Posts: 441
Under Solaris, I had to add a space before the {}. Otherwise it just hung with no path info. Reference: The argument {} is replaced by the current path name.

So,

find /cs252/Assingment/commandAsst/project/ -exec grep -l 'sequentialInsert' {} \;

Cheers,

Keith
  #6  
Old 12-18-2003
Registered User
 

Join Date: Dec 2003
Location: Fairfax, VA
Posts: 7
I finally got it to work...It was a problem with the -| in the command. I just took that out and it's working with no errors. Do you have any idea why that could cause an error in the command?
  #7  
Old 12-18-2003
kduffin's Avatar
UN1X
 

Join Date: Nov 2003
Location: Virginia
Posts: 441
It should be a grep -l (as in the letter in the alphabet). Your text is a grep -| (as in the pipe).

From the grep man page:

-l Print only the names of files with matching lines,
separated by NEWLINE characters. Does not repeat the
names of files when the pattern is found more than
once.

Cheers,

Keith
Google The UNIX and Linux Forums
Closed Thread

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0