![]() |
| | #1 |
| Registered User Join Date: May 2006
Posts: 1,579
| programming with grep I am programming with grep command in my C/C++ application to steal its string manipulation functions. :-) I have completed several simple cases. I am meeting issues with two cases, and I am wondering how to represent it in grep. 1. find the lines contain "foo" or "goo"; 2. find the lines contain "foo" but no "goo". could anyone help please? thanks in advance, George |
| George2 is offline | |
| | #2 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,640
| > I am programming with grep command in my C/C++ application to steal its string manipulation functions. :-) Ugh! Try using the regexp library which presents the same functionality as grep but without all the expensive overhead of spawning a separate process every time you want to do something. > 1. find the lines contain "foo" or "goo"; egrep '[fg]oo' |
| Salem is offline | |
| | #3 | |
| Registered User Join Date: May 2006
Posts: 1,579
| Thank you Salem! Quote:
regards, George | |
| George2 is offline | |
| | #4 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,640
| Code: egrep 'read|the|manual' file.txt |
| Salem is offline | |
| | #5 | |
| Registered User Join Date: May 2006
Posts: 1,579
| Cool Salem, thank you! Quote:
regards, George | |
| George2 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| simple grep problem | cdave | Windows Programming | 7 | 12-29-2005 05:48 PM |
| Grep Last Pattern Output | cfriend | Linux Programming | 1 | 09-18-2004 10:14 AM |
| Grep | cfriend | Linux Programming | 3 | 09-17-2004 05:34 AM |
| Grep | Adam | C Programming | 0 | 06-07-2002 06:06 AM |
| grep | Unregistered | C Programming | 3 | 02-26-2002 12:11 PM |