The Linux Find command is used for statistical information

Source: Internet
Author: User

1. Calculate the number of files in the current directory:

Find WC -l

2. Find the latest and oldest files in the/etc directory, sorted by file time and displayed in the format of year-month-day:

#查找最旧的文件 [[email protected] tmp]#Find/etc/-type f-printf"%t+%p\n"|Sort-N |Head-N1 -- Geneva- A+ +: at:47.0000000000/etc/lsb-release.d/graphics-4.0-ia32# Find the latest file [email protected] tmp]#Find. -type f-printf"%t+ \t%p\n"|Sort-N |Tail-N1 -- ,- .+ +: $:14.4790036700./student.txt

Note: In the printf command output,%t represents the date and time of the file, and%p represents the filename with the path

3. Check the home directory for "." Start with the latest file:

Find " %t+ \t%p\n " grep " ws/\. " Sort Tail 1 £ º+:22.4699979720  /home/ file

4. Find the largest file in the directory, the%s parameter represents the file size, the%f parameter indicates the Include file name

Find " %s \%f\n " Sort Uniq Tail 1 12288    . Crontab.vf6XP3.swp

5. The owner of the statistics file, using the%u parameter, and counting the number of files belonging to the same owner (can be implemented via UNIQ-C):

Find " %u\n " grep " \./\. " Sort Uniq -c     ,  root      1 ws

6. To view the date the file was accessed, use the%a parameter:

[Email protected] tmp]#Find. -type f-printf"%a+%p\n"|SortFri Jul - xx: -:36.0720998929  -+./SH/variable.SHMon-Aug3  at: $:49.0879000520  -+./. Viminfomon Jul -  at: One:37.0189000083  -+./SH/if1.SHMon Jul -  at: -:30.0823998314  -+./SH/readtest.SHMon Jul -  at: -:52.0296995712  -+./SH/readtest,SHMon Jul -  at: the:46.0718997111  -+./SH/if2.SH

7. Before running the command, temporarily empty the environment variables, you can use the Env-i command, to modify environment variables (ignoring environment variables), start a shell, the new shell does not have redundant environment variables

SH Env WC -l-shenvenvWC -l0 

The Linux Find command is used for statistical information

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.