课程: Linux: System Information and Directory Structure Tools

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Searching in files with grep

Searching in files with grep

- [Instructor] The most efficient way of searching for data in a file is to use grep. The syntax for grep is grep, followed by options and then the search criteria, usually placed within single quotes to protect the text from being processed by the shell, and lastly, the name of the file to search through. The other option is to pipe the output of a command into grep, which I often do. Grep has many options, but the ones I like to use the most are -i for case insensitive search, - v for inverted search, which shows the opposite of the search criteria, - c to return the number of lines that matched, useful for items and log files, - o to show only characters that match, normally, grep returns the entire line, - r to recursively search through all files on a directory, useful for finding items and configuration files in /etc, and lastly, -E to use extended regular expressions. Grep supports basic and extended…

内容