Home  >  Article  >  Operation and Maintenance  >  What are the usages of linux find command?

What are the usages of linux find command?

coldplay.xixi
coldplay.xixiOriginal
2020-12-16 12:04:419752browse

The usage of the linux find command is: 1. [find -name] to search directly based on the file name; 2. [find -perm] to search based on the file permissions; 3. [find -mtine -n( n )] Search based on the change time of the file.

What are the usages of linux find command?

Related learning recommendations: linux video tutorial

The usage of the linux find command is:

The find command is a command for finding files in the Linux system. Its biggest role is to help users quickly find the files they need when using the Linux system.

First introduce the directory path of find, which is divided into two situations:

  • "." represents the current directory

  • "/" represents the root directory

The common parameters and meanings of find command file query are as follows:

1, find -name: Search directly based on the file name, for example, find / -name a.txt: Find the a.txt file in the root directory

2, find -perm: Search based on file permissions, for example: find / -perm 777,: Find files with permissions 777 (rwx-rwx-rwx) in the root directory

3, find -mtine -n( n): Search based on the change time of the file, where -n represents files within n days, n represents files before n days, such as: find / - mtime -1: Find files modified within 1 day

4, find -type: Find files of a certain type, followed by some parameters:

-d: Directory

-p: Pipe file

-f: Ordinary file

-i: Symbolic link file

Use the find command to find the file , there are two ways of output:

1. find -print: standard output, for example: find / '*.NCT'-print >a.txt, represents Enter the file list named nct in the root directory into a.txt

2. find -exec: Execute the shell command given by this parameter for the file found by the find command, such as:

find -name test.txt -exec rm -f test.tx {} \;

Find test and delete this file. In this command, be sure to pay attention to the spaces between {} and \, and do not miss the last ";"

Related free learning recommendations: php programming(video)

The above is the detailed content of What are the usages of linux find command?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn