We all know that the command to find files under Linux is the find command. With this command, you can quickly find the files you want. What are the tips for using the find command? The following small series will introduce you to the clever use of the find command in Linux.
find command works by traversing downward along the hierarchy of the file, matching matching document, and perform the corresponding operation.
1, according to the file name or regular expression matching search
The option -name parameter specifies the string that the file name must match, we can use the wildcard as a parameter, “*. Txt” matches all filenames ending in .txt.
The code is as follows:
[root@localhost test]# touch {data,log,file,File,LOG}_{1,2,3,4,5,6}_{ .txt, .pdf, .log, .conf}
[root@localhost test]# find . -name “*.txt” –print
If you want to match one of several conditions, you can use the -o parameter.
The code is as follows:
[root@localhost test]# find . \\( -name “*.txt” -o -name “*.log” \\)
The option -iname ignores the case of letters
The parameters of the -path option can use wildcards to Match file paths or files.
2, Negative parameters
find with “! ” to negate the parameters, match all file names that do not end with .txt.
The code is as follows:
[root@localhost test]# find . ! -name “*.txt” –print
3, based on directory depth search
The find command will traverse all subdirectories when used, we can use -maxdepth and -mindepth To limit the depth of the find command traversal.
-maxdepth: Specify the maximum depth;
-mindepth: Specify the minimum depth.
The code is as follows:
[root@localhost ~]# find . -maxdepth 1 -type f
Lists all the normal files in the current directory, which are followed by the target path.
4, search according to the file type
The code is as follows:
find. –type d –print
File Type Type Parameter Normal File f Symbol File l Directory d Character Device c Block Device b Socket s fifo p Previous12Next Total 2 Pages
Ubuntu is a kind of Linux system. The biggest feature is that it has a software cen
Some users have just come into contact with ITDB, knowing that it is a PHP open source IT asset mana
Linux rz command and sz command can be used for file transfer, and rz command is ma
The Linux ps command is mainly used to check the running process of the system, and
Ubuntu 12.04 removes the Gnome Shell extension's tips
How to configure HTTP load balancing system
Why does a Linux system have w permissions but cannot delete files?
Linux iis can not run asp file how to solve
Linux uses KSysguard to monitor remote hosts
How to deal with the disappearance of ibus input method icon after upgrading Ubuntu 12.04?
How to configure the permissions of the Linux system sudo command?
The specific usage of the tee command in Linux system
Linux system to find ways to replace non-UTF-8 encoded files
How to identify open and fopen functions in Linux
Into win7 User Account Control (UAC) World (2) UAC options
Network is unstable, always limited
QQ mailbox to withdraw the sent mail step tutorial
Win8 boot automatic dial-up connection broadband graphic tutorial
[Chinese subtitles video] Win10 conference live video came! Highlights
16 Linux server monitoring commands you should know
Let the Windows 7 notification bar redisplay the power button
Teach you to quickly query the authorization information in Win7 pre-installed computer