I want grep all lines containing words that start with "H" and end with "d". How would i do that? I found that grep ^H will give me the H for everyline.
I would try:
/^H.*d$/. The ^ is the starts with and $ end with. The .* matches anything.
How do you define "words"?
If they're delimited by spaces:
grep '\<H[^ ]*d\>' ...
should do it.
\> match the beginning and end of a word, respectively.
[^ ]* matches a sequence of zero or more non-space characters.
More, generally, if your grep supports it (GNU grep does):
finds words delimited by "space" characters: tab, newline, vertical tab, form feed, carriage return, and space.
I'm assuming that "lines containing word" means that you want "foo H123d bar" to match. If each line contains an entire word, replace
EDIT: This might not be 100% correct.
\> define a "word" as a non-empty sequence of letters, digits, and underscores. Define exactly what you mean by "word", and I'll try to refine my answer. In
H*d a "word"?