grep command in Linux is used to search a specific pattern. Grep command will help you to explore the string in a file or multiple files.
The syntax for grep command:
- grep ‘word’ filename
-
- grep ‘word’ file1 file2 file3
-
- command|grep‘string’
-
- For example,
-
- grep “smith” passwd
-
- grep “smith” passwd shadow
-
- netstat -an | grep8083
-
- cat /etc/passwd | grep smith