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
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)
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
Summary: Unix and Linux changed a lot. It's true on one platform, but it might be false on another platform. It's true right now, but it's false in the later version. The following were tested on the following...
Summary: The [ -z "$variable" ] part checks for the existence of a variable. testvar=`cat $dir/ftp_session.log | egrep -v "bytes sent" | egrep -v "bytes received" | cut -c1 | grep '[4,5]'` egrep is similar to ...
Summary: I have to look for in a file an expression of the type: V[tab]0707xxxxxxxxxx and if I make it in interactive it works grep "V[tab]0707xxxxxxxx" file but inside a cshell not Thanks ...