Skip to content Skip to sidebar Skip to footer

How to Find the Words contained in the File on RHEL 7 Quickly

Hi everyone, I will show you a basic trick or command in Linux to speed up work. This command functions to find a word that is contained in your file or the configuration that you have done in that file.

grep searches the named input FILEs (or standard input if no files are named, or if a single hyphenminus (-) is given as file name) for lines containing a match to the given PATTERN.  By default, grep prints the matching lines.

In addition, two variant programs egrep and fgrep are available. egrep is the same as grep -E. fgrep is the same as grep -F. Direct invocation as either egrep or fgrep  is deprecated, but is provided to allow historical applications that rely on them to run unmodified.

This command is very basic: 

# grep -rnw 'directoryofyourfile' -e 'searchword'
# grep -rnw '/etc/httpd' -e '.conf'
command search word in file
command search word in file

The results that are displayed you can see the information :

  • /etc/httpd/httpd.conf.ori : Name of file
  • 56 : where the line of words are searched
  • Include conf.module.d/*.conf : one line that contains the word you are looking for
contens of the file
contens of the file
Bangkit Ade Saputra
Bangkit Ade Saputra Hard-working professional with experience and a proven knowledge of operating system, server architecture and system configuration.

Post a Comment for "How to Find the Words contained in the File on RHEL 7 Quickly"