In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the find command under Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the find command under Linux.
The find command under Linux is used to search for files in the directory structure and perform specified operations. The find command under Linux provides quite a number of search conditions and is very powerful. Even if the system contains a network file system (NFS), the find command is also valid in that file system.
It is important to note that when running a resource-consuming find command, we all tend to leave it in the background, because it can take a long time to traverse a large file system (in this case, a file system of more than 30 gigabytes).
1. Want to view files with the word "log" in their names in the current folder and subfolders
# find. -name "* .log"
. : represents the current directory
-name: indicates that you want to search by name.
two。 Want to check if there is a "xinsz" directory in the current folder and subfolders
# find. -type d-name xinsz
-type: indicates the setting type, d represents the folder type, and can be replaced with f (normal file), l (linked file)
3. Want to find all files in the current folder and subfolders with the suffix ".txt"
# find. -name "* .txt"
4. Want to find out what files the "roc" user has in the current directory and its subfolders
# find. -user roc
-user: used to set the name of the user to which it belongs, which can be replaced with-group, that is, the name of the user group to which it belongs.
5. Want to find all files in the current folder and subfolders with permissions set to 777
# find. -perm 777
-perm: used to set permissions
6. Want to find files in the current folder and subfolders that contain both b and 3 characters: using regular expression techniques
# find. -regex'. * b.room3'
-regex: indicates that regular expressions are used for matching. Note that this command matches the "full path", that is, it is preceded by. *, because there will be a ". /" symbol in the output.
7. If you want to output all the contents of the "* .abc" file found with the find command
# find. -type f-name "* .abc"-exec cat {}\
-exec indicates that the match found by find will be used as an argument to "commands set after-exec"
You can use-ok instead of-exec, so that the user is asked to confirm (y is yes, n is no) for each match.
Don't forget to write the last {}\; of the command, where {} represents every lookup item in the results found with find.
8. Find files in the current directory that have been modified within 10 minutes
# find. -mmin-10
Access with amin, modify with mmin, change file status with cmin
Accurate to minutes with amin,mmin,cmin, accurate to days with atime,mtime,ctime
Use-10 within 10 minutes and + 10 for more than 5 minutes
9. Want to find all files with a file size greater than 10m in the current directory and subdirectories
# find. -size + 10000000c
-size: indicates the file size, + indicates greater than a certain number, and-indicates less than a certain number. C indicates that the units are bytes. You can change c to k _ Magi _ M _ G.
10. All of the above find commands look for the current directory and its subdirectories. If you do not want to drill down into a subdirectory, but instead look for only the current level of directory, you can:
# find. -maxdepth 1-name "* .c"
11. Find all current directories and sort
# find. -type d | sort
Several hybrid applications:
1. Find files greater than 3m on disk:
# find. -size + 3000k-exec ls-ld {}
two。 Handcuff what find came out to another place.
# find * .c-exec cp'{}'/ tmp';'
3. Avoid multiple folders
# find test\ (- path test/test4-o-path test/test3\)-prune-o-print
\ means that the reference to shell does not make a special interpretation of the characters that follow\, leaving it to the find command to explain its meaning. Do not look for test4 and test3
At this point, I believe you have a deeper understanding of "how to use the find command under Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.