From the course: LPIC-1 Exam 101 (Version 5.0) Cert Prep
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Finding text in files with grep - Linux Tutorial
From the course: LPIC-1 Exam 101 (Version 5.0) Cert Prep
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
Simple and compound commands5m 59s
-
(Locked)
Modify the shell environment6m 42s
-
(Locked)
Command history3m 30s
-
(Locked)
The PATH and command execution3m 29s
-
Named and unnamed pipes3m 58s
-
(Locked)
Use input-output redirection (>, >>, |, 2>, etc.)5m 2s
-
(Locked)
Use text filters7m 3s
-
(Locked)
Find files using locate4m 51s
-
(Locked)
Finding files with find4m 47s
-
(Locked)
Finding text in files with grep5m 55s
-
-
-
-
-
-
-