How to Use Unix Grep Command

Published: 11 June 2013
on channel: HOWTECH
12,018
74

The Unix Grep Command in Linux can search for the document you need. You can even enter a word and all the files containing it will appear.

Don't forget to check out our site http://howtech.tv/ for more free how-to videos!
   / ithowtovids   - our feed
  / howtechtv   - join us on facebook
https://plus.google.com/1034403827176... - our group in Google+

In this tutorial we will show you how to use Unix Grep command
GREP stands for Global Regular Expression Print and is used for filtering the searches and finding what you are looking for. This makes the search for different files existing on your system easy. Amongst unix commands grep is one of the easiest to use and work with.
To understand how you can use the grep command, follow the steps given below.

Step 1 -- List the contents

Let's start by first listing the contents of the directory. To understand the concept of the grep command, we will first display the contents of this text file here.

Step 2 -- Search for a specific word in the text file

With that done, we will search for a particular word in the text file. For that, type grep space "the search query" followed by the name of the text file.
With that done, you will notice that the search query will be shown over here and it will automatically highlighted by red color.
This way you can use the unix grep command to search for a specific text file that you need.

Step 3 -- Use the "-c" attribute

If you want a simple count of how many times the search query is found, you can use the -c attribute over here.
Once we hit enter, you can see that the number of results are shown on the screen.
And that's it, from the above steps it can be seen that using the unix commands of grep are fairly easy and not at all time consuming. Therefore, to search a file in Linux, you can use this method and technique.


Watch video How to Use Unix Grep Command online without registration, duration hours minute second in high quality. This video was added by user HOWTECH 11 June 2013, don't forget to share it with your friends and acquaintances, it has been viewed on our site 12,018 once and liked it 74 people.