This question already has an answer here:
I have certain questions regarding grep.
Why does the following command match '
<Hello'?$ grep -E "\<H" test Hello World <Hello H<elloWhat needs to be done to match '
<Hello' only?
|
This question already has an answer here: I have certain questions regarding
|
||||
| show 1 more comment |
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
To prevent
Remember to quote the search pattern properly, otherwise it may be interpreted badly by your shell. For example, if you ran
As for matching words only, have a look at the manual page
Example usage (using the above test file):
( To match the beginning of a word, you do need regular expressions though:
|
|||||
|
|
In all To remove the special meaning of So to match
And to match
Note that both So that pattern matches the full line, add the
would match only lines whose content it exactly To match at the beginning of the line:
(would match To match
or with BRE:
|
||||
|
|
|
Ctrl-V is your friend. Ctrl-V tells the shell to treat the following character as a non-special character. So, for example,if you have a file that has a backspace character in a line, and you want to grep to find that line, try grep [Ctrl-V] [Backspace] filename |
|||
|
grep \' inputfile– Rahul Patil Mar 5 at 7:43<Hello" (no quotes) instead of "'<Hello'". Please clarify. – l0b0 Mar 5 at 16:32