![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to grep for a word and display only the word | ananthmm | UNIX for Dummies Questions & Answers | 6 | 05-29-2008 05:00 AM |
| Grep for Particular Word | reddi22 | Shell Programming and Scripting | 2 | 01-22-2008 07:36 AM |
| grep a word from a line | Orbix | UNIX for Dummies Questions & Answers | 2 | 12-23-2007 07:52 AM |
| Grep for X character on a word | jjoves | UNIX for Dummies Questions & Answers | 5 | 08-06-2004 02:14 AM |
| How to grep more then one word? | roco | UNIX for Dummies Questions & Answers | 5 | 10-18-2002 07:43 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
grep for word
Hi, I'm a little confused with the grep options and can't seem to find the correct one I need. I basically want to grep a file for a word with the pattern in it. I tried:
Code:
grep -w word file this is a file and here is someword I want it to return: someword |
| Forum Sponsor | ||
|
|
|
|||
|
grep -ow word will find "word" but not "someword". A pattern which matches the entire word in which the search pattern is embedded would be something like
Code:
grep -ow '[A-Za-z]*word[A-Za-z]*' file If you want "quote" marks, 'single' quotes, hyp-hens or abbr'viation apostrophes, you need to change the pattern slightly. Getting it perfectly right for all possible English words is not easy (and perhaps not even doable, depending on how you define "all", "possible", and "English"). |