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

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

How to Find 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

Conclusion

Mastering the grep command in Linux provides a quick and efficient way to find specific words contained within files on RHEL 7. By utilizing this command, users can streamline their work processes and swiftly locate relevant information within their configurations and files. 

Whether you're searching for specific keywords in system files or configurations, the grep command simplifies the task and enhances productivity. Incorporating this basic yet powerful command into your workflow will undoubtedly expedite your work and improve your efficiency on RHEL 7.

Maybe that's all I can share with you guys, hopefully this article will be useful.

Thank You 

Bangkit Ade Saputra
Bangkit Ade Saputra At the end of the day, my job involves people. we're complicated, we're always changing, we have millions of things going on in our lives, and changing jobs is always a big decision.

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