![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| find , grep | james94538 | UNIX for Dummies Questions & Answers | 3 | 10-09-2008 09:03 PM |
| grep, find or awk? | netrom | UNIX for Dummies Questions & Answers | 4 | 04-09-2008 05:03 PM |
| find then grep | flame_eagle | Shell Programming and Scripting | 7 | 03-13-2008 11:19 AM |
| find and grep | sarwan | High Level Programming | 4 | 04-10-2006 07:05 AM |
| find & grep | Anika | UNIX for Dummies Questions & Answers | 11 | 02-01-2001 12:19 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grep and find
Hey, I have a question about using grep and find together to locate all C programs in a directory containing certain words and open the vi editor with each file. I'm not sure how to do this in one command (as in one line). I know find has a "-exec" option that can call vi, but how do you combine this with grep to find only those containing the words "int main ("? Thanks
|
|
||||
|
This should work:
find ~ *.c -exec vi `grep -l "int\ *main\ *("` {} \; find finds all files *.c and executes vi provided that grep finds the string "int main(". The -l in grep returns the filename. Merely out of curiosity: 1) Is this 11.19.ii in "Your Unix The Ultimate Guide" by Das? 2) Are you in Sean's class at UCD? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|