Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Console Foundations Installing Software Building Software From Source

what is grep ?

what the function of grep and how to use it ?

2 Answers

Hey Nihanth,

grep is a command-line tool for searching the contents of a given file or files according to a specified criteria. For more information on how to use it, you can check the documentation straight from your terminal: just type in man grep.

Kepa Tairua
Kepa Tairua
Courses Plus Student 4,404 Points

I'd just add that (based on the lessons), it searches a given input for a pattern. The input could be a file, could be from the standard input (keyboard), or using pipes could be from the output of another process.

The grep command is used to search text or searches the given file for lines containing a match to the given strings or words.

here is an example:

$ grep 'word' yourFileName