AboutWelcome to Free Software Daily (FSD). FSD is a hub for news and articles by and for the free and open source community. FSD is a community driven site where members of the community submit and vote for the stories that they think are important and interesting to them. Click the "About" link to read more...
The grep command is a hugely powerful way to search through files. Like many command line utilities, once you're comfortable using it, you will discover that it is surprisingly fast and accurate.
This article covers two beneficial Linux tools, grep and sed. If searching for or handling text, grep and sed can increase your efficiency with Linux bash scripting and configuration files. We'll learn how to use these commands and get some helpful tips, too.
"...In this article let us review 15 practical examples of GNU grep command that will be very useful to both newbies and experts..." -- See also Introduction to the GNU/Linux Command Line:
* flossmanuals
* GNU Press
Global Regular Expression Print is the rather un-catchy full name of grep, the staple of any Linux users toolkit. It is a search tool run from the command line that is evolved directly from Unix, and is so useful it deserved a post of its own.
The grep search utility is one of the most essential building blocks of command line text filtering and processing. In this tutorial, we will give you a few simple examples.
Here's a brief example of applying a regex, drawn from the UNIX command-line utility grep, which searches for a specified pattern among the content of one or more UNIX text files. The command grep -i -E '^Bat' searches for the sequence beginning-of-line (indicated with the caret, [^]), followed immediately by upper- or lowercase letters b, a, and t (the -i option ignores case in pattern matches, so B and b are equivalent, for instance). Hence, given the file heroes.txt:
Seriously the command line does it for me, gets me all hot and bothered ;). I just love having all the tools (including the shell itself) to be able to do what I need to do.