Search for keywords from files
Grep 'linux 'text.txt // search for keywords containing Linux
[Root @ localhost ~] # Grep 'root'/etc/group
Root: X: 0: Root
Bin: X: 1: Root, bin, daemon
Search for keywords from multiple files
[Root @ localhost ~] # Grep 'root'/etc/group/etc/My. CNF
/Etc/group: Root: X: 0: Root
/Etc/My. CNF: User = root
Search for all files containing the STR string in the current directory and the subdirectories under its jurisdiction. The file names and contents of the row and the row number are listed.
-N indicates the row number, and-R indicates the row number to be queried in the subdirectory.
Grep-n "str"-R ./
Case sensitivity can be ignored when searching with-I
Perform corresponding searches under all subdirectories and use-R to complete
Use-L to print all the results.
Grep-RIL 'str './
Find is a common command for searching files.
Search for all files with mail in the/etc directory.
[Root @ localhost] # Find/etc/-name '* mail *'
/Etc/mail. RC
/Etc/rc. d/rc5.d/k30sendmail
/Etc/rc. d/rc4.d/k30sendmail
Find the file whose size exceeds the specified value
[Root @ localhost] # Find./-type F-size + 100 m
./Test. SQL
Files modified in recent days
Find.-mtime-2