×

17 examples of using Grep command in Linux

This article will guide you on the basic syntax and usage of the #grep #command in #Linux. We also went through some command-line options to expand its usefulness. The easiest of the two #commands is to use grep's -w option. This will find only lines that contain your target word as a complete word. 

Run the command "grep -w hub" against your target file and you will only see lines that contain the word "hub" as a complete word.

1. grep searches one or more input #files for lines that match a given pattern and writes each matching line to standard output. 

2. If no files are specified, grep reads from the standard input, which is usually the output of another command.