In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about how to use commands in linux to find files vaguely. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
Find a file vaguely based on its name
For example:
In the directory / var/zcwyou, find the file with the .txt suffix, the file name is case-sensitive. That is, it can only match the .txt suffix
[root@zcwyou ~] # find / var/zcwyou-name'* .txt'
In the directory / var/zcwyou, find the file with the .txt suffix and ignore the resizing. You can match the .txt suffix, the .Txt suffix, or the file with the .TXT suffix.
[root@zcwyou ~] # find / var/zcwyou-iname'* .txt'
3. Find files vaguely based on file name and file content
How to use it:
Combine the find command with xargs and grep-I 'target matching keywords'
Case 1:
Search the current directory for files that contain a string (case-sensitive):
Syntax:
Find / etc/-type f | xargs grep 'target keyword'
Case 2:
In the / etc/ directory, look for the file with the zcwyou keyword
[root@zcwyou ~] # find / etc/-type f | xargs grep 'zcwyou'
You can find the following files and their corresponding contents:
/ etc/group-:zcwyou:x:1000:
/ etcram gshadowshadowlu zcwyoulu zcwyougshadowlu
/ etc/passwd-:zcwyou:x:1000:1000:zcwyou:/home/zcwyou:/bin/bash
/ etc/group:zcwyou:x:1000:zcwyou
/ etc/shadow-:zcwyou:
Is it very efficient?
Case 3:
Search the current directory for a specific file that contains a string (ignoring case):
Borrow the find command to find all files ending with the .c suffix in the current directory and files ending with the .c suffix in the subdirectory, and pass the results as parameters to grep, which is searched and filtered by grep.
[root@zcwyou] # find. -type f-name'* .c'| xargs grep-I 'target search keyword'
4. Use the `find` command to vaguely find linux files
In the current directory, fuzzy search for files accessed in the last 10 minutes of the system
[root@zcwyou] # find. -amin-10
In the current directory, fuzzy search for files accessed in the last 48 hours in the system
[root@zcwyou] # find. -atime-2
In the current directory, look for files or folders that are empty in the system
[root@zcwyou] # find. -empty
In the current directory, find the files that belong to group cat on the system
[root@zcwyou] # find. -group cat
Fuzzy search for files that have been modified in the last 5 minutes in the system
[root@zcwyou] # find. -mmin-5
Find files that have been modified in the last 24 hours of the system
[root@zcwyou] # find. -mtime-1
5. Fuzzy search for Linux files based on user attributes
Find files that belong to invalid users in the system
[root@zcwyou] # find. -nouser
Find the files that belong to the user zcwyou in the system
[root@zcwyou] # find. -user zcwyou
6. Find files by blurring the file size
Find more than 1m files in the root directory and print
[root@zcwyou] # find /-size + 1m-type f-print
Find files equal to 500 bytes in the current directory, including subdirectories, and print the results
[root@zcwyou] # find-size 500c-print
Find files less than 600k in the home directory
[root@zcwyou] # find / home-size-600k-print
7. Find new and old files through files
Find files newer than old.txt
[root@zcwyou] # find-newer "old.txt"-type f-print
Find files older than newer.txt
[root@zcwyou ~] # find!-newer "newer.log"-type f-print
Find files newer than old.txt and older than newer.txt
[root@zcwyou] # find-newer 'old.txt'!-newer' newer.txt'-type f-print what is a Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
The above is how to use the command in linux to find files vaguely. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.