To search for a character with special meaning in a regex like the period, you need to "escape" the character with a backslash like this:
Code:
grep \. SomeTextOrFileWithA.InIt
Like TheFu I usually enclose any regex search string in single quotes. That convention is used throughout the shell to have it treat the string inside the quotes literally. So the command above could also be written:
Code:
grep '.' SomeTextOrFileWithA.InIt
The shell distinguishes between single and double quotes. With double quotes, bash first replaces any references to "environment variables" with their assigned values before interpreting the string. So
Code:
echo "Show me my $HOME"
would return
Code:
Show me my /home/seijisensei
with my actual home directory substituted for $HOME. If instead I used the command
Code:
echo 'Show me my $HOME'
it would return
There are a lot of good guides to regular expressions on the Web. Just search Google for "regular expression".
Bookmarks