![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep, find or awk? | netrom | UNIX for Dummies Questions & Answers | 4 | 04-09-2008 02:03 PM |
| find then grep | flame_eagle | Shell Programming and Scripting | 7 | 03-13-2008 07:19 AM |
| find , grep | james94538 | UNIX for Dummies Questions & Answers | 2 | 02-01-2008 01:34 PM |
| find and grep | sarwan | High Level Programming | 4 | 04-10-2006 04:05 AM |
| find & grep | Anika | UNIX for Dummies Questions & Answers | 11 | 02-01-2001 08:19 AM |
|
|
LinkBack | Thread Tools | 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
|
| Forum Sponsor | ||
|
|
|
|||
|
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? |
|||
| Google UNIX.COM |