linux find files and content

linux find files and content

Find files

find path -option 操作

The path search path
"/" represents the linux root directory and its subdirectories
"." represents the current directory and its subdirectories
...

Option search rules
-name name: search by name
-ctime n: files that have been modified in the past n days
...

Find a file or folder based on the file name. For example, find the file or folder
named at the beginning of city in the root directory and its subdirectories. "/" means the subdirectory of the linux root directory.

find / -name "city*"

As a result, a city folder under usr and a jar file under the root path were found. For
Insert picture description here
example: Find the file or folder named at the beginning of city in a named way under the root directory, and list its detailed information

find / -name "city*" -ls

The results are as follows:
Insert picture description here

For example: List all files in the current directory and its subdirectories that have been updated in the last 10 days

find . -ctime -10

As a result, the files created a few days ago will be displayed, created on 8.28, within 10 days, so it can be found
Insert picture description here

Find the qualified string in the file

grep 查询条件 文件

Take a.txt as an example, the content of the file is as shown in the figure below,
Insert picture description here
such as: Find the "ceshi" string in the a.txt file

grep ceshi a.txt

The results are as follows:
Insert picture description here

Simple record, if you have any questions, please raise them, thank you

Guess you like

Origin blog.csdn.net/nongminkouhao/article/details/108315513