I executed a search with grep
, but it doesn't work like I expected it to. I have the following lines in a file:
blacklists/redirector/domains:needyoutube.com
lacklists/redirector/domains:openyoutube.com
blacklists/redirector/domains:proxy-youtube.com
blacklists/redirector/domains:proxytoyoutube.com
blacklists/redirector/domains:streamyoutube.com
blacklists/redirector/domains:unblockyoutube.com
When I run:
grep ':youtube.com'
I get no results. The following works:
grep 'youtube.com'
How can I escape the colon (:
)? Backslash (grep '\:youtube.com') doesn't work. I use RHEL 5, grep (GNU grep) 2.5.1.
Update:
I forgot the entries I wanted to grep, these exist also:
./blacklists/movies/domains:youtube.com
./blacklists/movies/domains:youtube.com.br
I want to just get the fields that contain the exact domain name. So I want to get the blacklists linked to youtube.com, so I use ":youtube.com".
From the list above (youtube.com, youtube.com.br), I only should get youtube.com, but I don't get anything.
I wasn't clear enough, sorry.
Best Answer
Looks like "blacklists/redirector/domains" is actually a filename, not part of the file's content.
grep ':youtube.com'
works just fine:If you want to recursively find lines that starts with "youtube.com" use
grep -R '^youtube\.com' path/to/dir