Computing.Net > Forums > Unix > grep and egrep

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

grep and egrep

Reply to Message Icon

Name: phgct2004
Date: March 29, 2004 at 23:18:05 Pacific
OS: linux 9.0
CPU/Ram: 866/128
Comment:

hi,

i have few question regarding the using of grep to search for a word in the /usr/share/dict/words directory

1. how can i find all the words containing both an "x" and a "k" using grep -E.
i try using = "grep -E *x.*k|*k.*x /usr/share/dict/words " but the resuct is only for *k.*x and *x.*k is not show?

2. All words containing a single "z" that is not adjacent to a vowel (this include words ending or starting with z)


phgct



Sponsored Link
Ads by Google

Response Number 1
Name: aigles
Date: March 30, 2004 at 06:31:02 Pacific
Reply:

1) Words containing "x" and "k" :
grep -E 'x.*k|k.*x'

1) Words containing a single "z" not adjacent to a vowel :
grep -E '(^|[^aeiou])z([^aeiou]|$) | grep -Ev 'x.*x'

Jean-Pierre.


0

Response Number 2
Name: Dlonra
Date: March 30, 2004 at 12:02:51 Pacific
Reply:

you should always try "man grep"

is /usr/share/dict/words a directory or file?

man ksh or man bash - REs should be in quotes



0

Response Number 3
Name: phgct2004
Date: March 30, 2004 at 20:04:40 Pacific
Reply:

hi,

how about i want use only 1 grep instead of 2 to search for a single "z" that is not adjacent to a vowel? (this will include words starting and ending with z)

thank


phgct


0

Response Number 4
Name: aigles
Date: March 31, 2004 at 08:07:48 Pacific
Reply:

Try this :

grep -E '^([^z]*[^zaeiou])?z([^zaeiou][^z]*)?$'

and now a new exercise for you : explain the command ...

Jean-Pierre.


0

Response Number 5
Name: phgct2004
Date: April 1, 2004 at 01:03:34 Pacific
Reply:

hi,

thank for your help.

chui


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: grep and egrep

Script to scan files for a string www.computing.net/answers/unix/script-to-scan-files-for-a-string/7532.html

a simple question about grep and -z www.computing.net/answers/unix/a-simple-question-about-grep-and-z/4532.html

grep and tabulator www.computing.net/answers/unix/grep-and-tabulator/7736.html