The Find command, which is used as often as a CD. It is only possible that the majority of the time it takes only one or two parameters to be used. Or, barely enough. But when we take the initiative to look at the manual of Find, we will find that the original more practical functions are not practical.
This article is a simple introduction to find using your own use. Not guaranteed to be comprehensive, just list the options I've benefited a lot from using.
Find dir [option] Specifies the current folder to be searched.
option can be omitted, and if omitted, find recursively lists all the files in the current folder.
The frequently used option has a very great number, listing only the parts that are used frequently:
-NAME Specifies the name of the file, the ability to use wildcards, assuming that the use of wildcards, you need to use a double-lead extension.
-TYPE Specifies the type of file, optional type contains normal file f folder file D symbol file L character device C block device B etc.
-size can be followed by a +-n +n represents a file that exceeds n specified size, and-n indicates a size less than n specified.
-newer file lists the current folder and subfolders, new to the specified file
-mtime +-n is similar to the size option, +n indicates that the change time is older than the specified n*24 disappears.-N indicates that the change time is new to n*24 disappear.
-ctime +-n Ibid, just represents the time the state of the file changed, note that find does not have the so-called Search by creation time
-atime +-n Ibid., the benchmark to find is the time to visit.
-maxdepth Maximum folder depth. This option is specified to prevent find from endlessly traversing subfolders.
-depth This option means to process a folder and then go through the subfolders.
-and is used for conditions that can specify multiple conditions, and the returned result is a file that satisfies all conditions
-or Ibid, just return is the one that satisfies the condition can be.
! Put it in front of the option and see how he uses it later. Used to specify a file that does not meet the criteria.
-exec command [option] {} \; Non-interactive Run command to run all the files found by find. Note the spaces between {} and \.
-OK command [option] {] \; Run the command interactively to run the file found by find, but you will be prompted for confirmation.
-delete the files that are found are deleted.
The above should be able to cope with most of the scene. There is actually another reason why you can use find. I found it inadvertently. When there are more files in a folder. Maybe you want to. Run command: ls "*.txt" | Xargs Cat
A command that appears to have no problem can occur incorrectly. The reason is that there are too many files. This command is not available, and find will come in handy at this time. There must be something different about find.
Let's look at the application of find in practice.
1. Locate the normal non-sh suffix file for the current folder and run the cat
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy3azywxhaq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
2. List non-sh and txt suffix files
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy3azywxhaq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
There are two possible ways to do this. Note that there must be a space between the options, or you will get an error. Notice that there are spaces between the parentheses and the options, otherwise you will get an error.
The effect of parentheses may not be very obvious today. I could not think of a detailed example at the moment. In short, the assumption is that there are no parentheses, there is a scenario where multiple conditions are filtered and using the-exec option,- The command after the EXEC option runs only the last file that is filtered by the specified option. Well, I've had this problem. But I can't figure out the scene. Shame.
3. list files larger than a certain size for the current file
It is important to note that when no unit is specified, the number behind the size is a block of 512byte. So don't take it for granted that it's a byte.
The approximate use of find is summed up so much. There must be a lot of incomplete, but the option of find is not difficult to understand, so the comparison option can also write a statement.
8 Shell Command's find