Linux command-find keywords in files

1. Open the file with vi or vim

How to find keywords in vi and vim editing mode in Linux:

1. Enter vi. In editing mode, first press "esc" on the keyboard to jump to command input mode.

2. Enter the slash "/", then the screen will jump to the bottom and "/" will appear in the input field.

3. Enter the keyword you need to find and press Enter.

4. If you want to continue searching for the next keyword, enter n

5. To find the previous keyword, enter N (capital)

2. The cat-- file is in the current folder directory and has not been opened.

cat filename | grep "keyword"

3. If gerp is to search for keywords contained in the content in multiple files in a certain directory,

grep -r "keyword" directory

Guess you like

Origin blog.csdn.net/m0_58823014/article/details/131070736