Home >Operation and Maintenance >Linux Operation and Maintenance >How to perform conditional query in linux
In Linux, conditional query can be implemented through the "find" command. Its syntax is such as "find / -name file", which is used to specify the directory search. The parameter "-name" represents the target name.
The conditional search command in Linux is the find command.
Linux-The operation method of using the file search command find is as follows:
1. Search the entire disk or specify a directory search. find Search directory -name target name, find / -name file
2. In this way, the search will see an exact match of file, which is case-sensitive. You can use -iname, which is not case-sensitive, find / - iname file. In this way we can find more relevant files in uppercase letters.
3. We first use the * wildcard character to match the relevant files containing file. It is case-sensitive: find / -name *file*. Case-insensitive: find / -iname *file*. If you match like this, there will be more files, and the more precise the match, the easier it will be for searching.
4. find search directory -size file size. Next we search for files larger than 100MB, which should actually be 102400KB*2. All search commands are: find / -size 204800. The - sign means less than, writing the number directly means equal to.
5. find search directory -user username. Here is the search for files belonging to the username user1. How to add and delete usernames in Linux, you can refer to the Linux user management command: find / -user user1.
6. Find search directory -type d. Find all directories under a directory: find /tmp -type d.
7. Find search directory -cmin -time (unit: minutes). Search for files modified within 1 hour under etc. There are too many files under the root directory. Specify a directory: find /etc -cmin -60.
8. Of course, the find command can add multiple options to the query: -a means that both the pre and post conditions must be met, -o means that only one condition is met, so that we can clearly see the filtered items document.
The above is the detailed content of How to perform conditional query in linux. For more information, please follow other related articles on the PHP Chinese website!