Use of the Find command under Linux

Source: Internet
Author: User

Use of Find
File Lookup
Find. (current directory)-name
Find. -name "*.txt"-print
Find. -name ' [a-z,a-z,1-100]* '. Txt-print
Find. -name "1.txt"-prune-o-name "*.txt"-print
Directory Lookup
Find. -path "./aa"-prune-o-name "*.txt"-print
Find. -path "./aa"-prune-o-path "./bb"-prune-o-name "*.txt"-print

Permission Lookup
Find. -prem 775-print
Do not look for the file under AAA find. -path "./aa"-prune-0-perm 775-print
Find. -path "./aa"-prune-0-path "./bb"-prune-o-perm 775-print
Find. \ (-path "./aaa"-o-path "./bbb" \)-prune-o-perm 775-print

Find by Type

Soft joins can be understood as shortcuts
Ln-s./aaa/*./ddd
Find.-type l-print

Search by Owner
Find/-user Www-type F-print
Find owner is deleted
Find/-nouser-type F-print

Find/-group apache-type-f-print

Find by Time
It was changed in two days.
Find.-mtime-2-type F-print
It was changed two days ago.
Find.-mtime +2-type F-print
It was changed 10 minutes ago.
Find. -cmin +10-type F-print

Follow the file old and new search

Find a new file than Aa.txt
Find. -newer "Aa.txt"-type f-print
Look for older files than Aa.txt
Find. ! -newer "Aa.txt"-type f-print
Looking for newer than bb.txt older files than Aa.txt
Find. -newer "Aa.txt"! -newer "Bb.txt"-type f-print

Find by File size
In the root directory smaller than 1M
Find/-size +1m-type-print
Files less than 1M
Find/-size-1m-type-print
Execute command
Find.                   -name "1.txt"-ok rm {} \; New Touch 12a.txt
Find. -name "12a.txt"-exec cp {}{}.bak \;

grep match
Cat 1.txt | grep all--color as soon as all cat 1.txt appears | Grep-w "All" matches a word
Cat-n
Take counter
Cat 1.txt | Grep-v-W "All"
Number of statistics
Cat 1.txt | Grep-c "All"
Number of rows displayed
Grep-n "All"
Show matching files
grep "All" 1.txt 2.txt 3.txt
Grep-l "All" 1.txt 2.txt 3.txt Show only the matching filenames

Grep-i "All" *.txt case-insensitive matching

System service Management

Chkconfig--list Show all services currently running
/etc/inittab
Netstat-antl all n port T TCP protocol L listen Status
Chkconfig--add httpd Increased service
Chkconfig--del httpd Delete
Chkconfig--level 12345

Use of the Find command under Linux

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.