In the previous command, we knew we could use cat to view the contents of a text file, but sometimes we didn't need to look at everything, but we needed to see a line that contained some information, such as in infiltration we need to see if some of the profiles contain sensitive information, such as password information, database connection information, etc. You can quickly see what we need to see by using grep!
Use the following syntax:
grep finds files for content to find
If the find content contains spaces, then you need to add a single quotation mark ', such as:grep ' Test hh ' Filenema, in addition, you can find in more than one file, continue to add the file name directly behind!
[Email protected]:~/linuxcmd# grep root/etc/passwdroot:x:0:0:root:/root:/bin/bash[email protected]:~/linuxcmd#
[Email protected]:~/linuxcmd# grep root/etc/passwd/etc/shadow/etc/passwd:root:x:0:0:root:/root:/bin/bash/etc/ Shadow:root:$6$8ur2a64j$y2oc5c6qstrtj1tpfpjkdiafxzsm8rj0iizfm32mn.ac.ubuggtq1ht2kgvnx4lfgukbj/poljzg32vjptbjs. : 17103:0:99999:7:::[email protected]:~/linuxcmd#
This article is from the "eth10" blog, make sure to keep this source http://eth10.blog.51cto.com/13143704/1955922
Linux command--grep