Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Linux find specific files

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you how Linux finds relevant knowledge points about specific documents. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Whereis

Find the installation path of the software

-b only look for binary files

-m only find help files

-s only find the source code

-u excluding files of the specified type

-f displays only the file name

-B look for binaries in the specified directory

-M looks for help files in the specified directory

-S finds the source code in the specified directory

Locate

Search for files in the file index database

-d search the specified database

Updatedb

Update file index database

Find [path]

Find a file

-name looks for files based on file names

-iname looks for files based on file names, ignoring case

-path looks for files according to the path

-ipath looks for files according to the path, ignoring case

-Files accessed by amin in the past N minutes

-Files accessed by atime in the past N days

-cmin files modified in the past N minutes

-ctime files modified in the past N days

-anewer files that have been read later than reference files

-cnewer files that have been modified later than the reference file

-size finds files based on file size (in b c w k M G)

-type looks for files based on file type. B block device c character device d directory p pipe file f normal file l link s port file

-user finds files by home user

-uid finds files by UID

-group finds files by belonging group

-gid finds files by GID

-empty looks for empty files

Example

# find / usr/-name'* mycat*' queries the path of the file containing mycat in the file name

# find / usr/-name 'mycat*' * query the path of a file whose file name begins with mycat *

# find / usr/-name'* mycat' * * query the path where the file name ends with mycat * *

Find lines that match the specified string from the contents of the file:

$grep "found string" file name

Find the line that matches the regular expression from the contents of the file:

$grep-e regular expression file name

Case-insensitive lookups:

$grep-I "found string" file name

Find the number of matching rows:

$grep-c "found string" file name

Find lines that do not match the specified string from the contents of the file:

$grep-v "found string" file name

Start from the root directory to find all text files with the .log extension and find the lines that contain "ERROR"

Find /-type f-name "* .log" | xargs grep "ERROR"

After the system finds the httpd.conf file, it immediately displays the httpd.conf file information on the screen.

Find/-name "httpd.conf"-ls

Look for a file in the root directory

Find. -name "test"

Find a file containing a string in a directory

Grep-r "zh_CN". /

These are all the contents of the article "how to find specific Files in Linux". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report