Searching with GREP

GREP, which stands for global regular expression print, is a sophisticated Linux/Unix tool that can serve many purposes, but one useful purpose on a dedicated server is its ability to search files and directories. With grep you can search within multiple files with relative ease. You can also parse printed screen data to simplify results.
To search a file, just enter “grep” followed by the search term and then the filename. For example, to search the file “httpd.conf” for the word “localhost”, you would type:
grep localhost httpd.conf
To use grep, to simplify printed screen lists, use the following format:
ls -al /usr/bin | grep make
This will list all of the files in the /usr/bin directory, but will only display those files that contain the word “make”. For more in-depth documentation, including use of regular expressions, type “man grep” from the command line.
Photo Source: Wikimedia Commons
Tag: command, dedicated server, grep, linux, regular expression, unix
Grep: A Powerful Search Tool

Grep is a powerful Linux tool that can make finding things much easier. If you have SSH access to your server and need to find something lost in your big mess of files, grep can help. A simple way to use grep is:
grep "modern" /home/user/public_html/podcasts.opml
This command will search for the word “modern” in the podcasts.opml file and print any lines that contain it.
Grep can also be appended to other commands to narrow down lists. For example, you can list every file in your /usr/bin directory but single out commands that contain the word “make”:
ls -al /usr/bin | grep make
You can even use it with the ps command to read information about a particular process:
ps aux | grep httpd
This post only scratches the surface of grep’s power. To learn more about grep, type “man grep” from the command line.
Photo Source: Flickr
Tag: command, grep, linux, server, ssh