Linux CentOS7 VMware Find command, file name suffix

Source: Internet
Author: User

A. Find command

The Find command in a Linux system is useful and convenient when locating files. It can find files based on different criteria, such as permissions, owner, date/time modified, file size, and so on. In this article, we'll learn how to use the Find command and the options it provides to find files.

List all files in the current directory and sub-directories

[[email protected] ~]# find
.
./.bash_logout
./.bash_profile
./.BASHRC
./.CSHRC
./.TCSHRC
./.ssh

Search all files and directories: find/etc/-name "xxx*"

[Email protected] ~]# find/etc/-name "ssh*"
/etc/ssh
/etc/ssh/sshd_config
/etc/ssh/ssh_config
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/ssh_host_ecdsa_key
/etc/ssh/ssh_host_ecdsa_key.pub
[Email protected] ~]#

Search Directory, example: find/etc/-type d-name "xxx"

[[email protected] ~]# find/etc/-type d-name "SSH"
/etc/ssh
/etc/selinux/targeted/active/modules/100/ssh
[Email protected] ~]#

Search for files, example: find/etc/-type f-name "xxx"

[[email protected] ~]# find-type f-name "*"
./.bash_logout
./.bash_profile
./.BASHRC
./.CSHRC
./.TCSHRC
./.ssh/known_hosts
./.bash_history
./anaconda-ks.cfg.01
./anaconda-ks.cfg.1

Search files by file type

[Email protected] ~]# find/etc/-type l

[Email protected] ~]# find/etc/-type D

[Email protected] ~]# find/etc/-type b

[Email protected] ~]# find/etc/-type C

View file details, stat 1.txt

[[email protected] ~]# ls
1.txt anaconda-ks.cfg.01 anaconda-ks.cfg.1 davery make Uear1 user1
[Email protected] ~]#
[Email protected] ~]#
[Email protected] ~]# stat 1.txt
File: "1.txt"
Size: 6 blocks: 0 IO blocks: 4096 directories
Device: 803h/2051dinode:652696 Hard Link: 2
Permissions: (0755/drwxr-xr-x) Uid: (0/root) Gid: (0/root)
Environment: UNCONFINED_U:OBJECT_R:ADMIN_HOME_T:S0
Last visited: 2018-03-30 21:57:22.470173086 +0800Access:-atime
Last modified: 2018-03-29 00:12:37.656441521 +0800Modify:-mtime
Last modified: 2018-03-29 00:17:05.797933042 +0800Change:-ctime
Creation Time:-Birth
[Email protected] ~]#

View the information changed within 1 days of/etc

[Email protected] ~]# Find/etc/type f-mtime-1
/etc/
/etc/resolv.conf
/etc/cron.daily
/etc/group
/etc/gshadow
[Email protected] ~]#

View information about changes in/etc within 60 Minutes

[Email protected] ~]# find/etc/-type f-mmin-60
/etc/resolv.conf
/etc/group
/etc/gshadow
[Email protected] ~]#

Finding files larger than 1000k

[Email protected] ~]# [[email protected] ~]# find/etc/-type f-size +1000k
/etc/udev/hwdb.bin
/etc/selinux/targeted/active/policy.kern
/etc/selinux/targeted/contexts/files/file_contexts.bin
/etc/selinux/targeted/policy/policy.30
[Email protected] ~]#

Find larger than 1000k files and show size

[Email protected] ~]# find/etc/-type f-size +1000k-exec ls-lh {} \;
-r--r--r--. 1 root root 7.2M March 06:09/etc/udev/hwdb.bin
-rw-r--r--. 1 root root 3.6M August 6 2017/etc/selinux/targeted/active/policy.kern
-rw-r--r--. 1 root root 1.4M August 6 2017/etc/selinux/targeted/contexts/files/file_contexts.bin
-rw-r--r--. 1 root root 3.6M August 6 2017/etc/selinux/targeted/policy/policy.30
[Email protected] ~]#

Second, file name suffix

Need to be case sensitive

[[email protected] ~]# ls
1.txt anaconda-ks.cfg.01 anaconda-ks.cfg.1 davery make Uear1 user1
[Email protected] ~]#
[[email protected] ~]# Ls
-bash:ls: Command not found
[Email protected] ~]#

Linux CentOS7 VMware Find command, file name suffix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.