From the course: Cert Prep: LPIC-1 Exam 101 (Version 5.0)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Finding text in files with grep

Finding text in files with grep - Linux Tutorial

From the course: Cert Prep: LPIC-1 Exam 101 (Version 5.0)

Start my 1-month free trial

Finding text in files with grep

- [Instructor] The most efficient way of searching for data in a file is to use grep. Grep shows lines in the file that match the provided search criteria. The syntax is grep followed by options and then the search criteria and lastly the name of the file to search to. Grep has many many options, but the ones I like to use most are -i for case insensitive searches, - v for inverted searches, which shows the opposite of the search criteria, - c for the number of lines that matched, - o to show only characters that match not the entire line, - r to recursively grep, this searches through all files in a directory, and -E to use extended regular expressions, this is the same as using egrep. There are many many more options. View the grep man page for more information. This example of using options shows a case insensitive search for the word root in /etc/password. You can also pipe the output of any command into grep. In…

Contents