How Do I Use Grep

This lesson will teach you how to use the grep command.

Go to the directory that contains the file you want to grep. In the example, the directory is /home/sitecon/sc.

From the command line, type grep "text searched for" filename. In the example, we are searching the Syslog for saleOver.

This command will show every instance of the searched text within the file searched.

To put the search results into a txt file, type grep "text searched for" filename > txtfile.txt. In the example all of the saleOver results were put into a txt file called saleover.txt.

Searching in multiple files

To search in more than one file, use the grep command as normal, but for the filename, use a wildcard. In the example Pos 1 authorizing 300.00 was searched for in all of the Syslogs in the logs directory.

The results are shown with the file they were found in on the far left.

0 Comments

Add your comment

E-Mail me when someone replies to this comment