Linux File Search

Source: Internet
Author: User

 

1. locate ---> searches for the database generated in advance, fuzzy searches, and updatedb updates the locate database.
-I: Ignore the case sensitivity of file names.
-N: only show the first n rows. For example: locate-n 3 passwd
2. find ----> real-time search, exact matching of file names
Find [DIR...] [CRIERIA] [ACTION...]
DIR:/root/home .. (default current directory)
ACTION;
-Print (default)
-Ls
-OK COMMAND: Interactive COMMAND Execution
-Exec COMMAND: non-interactive COMMAND Execution
Xargs executes and creates commands from standard output
Eg; find/root-name "[[: alpha:] [[: digit:]"-exec mv {}{}\; // {} indicates the search result, which must end \;
Find/root-name "[[: alpha:] [[: digit:]" | xargs chmod 755
CRIERIA:
-Name: accurate to the specified file name
-Iname: search by file name, but case insensitive
-User: search by owner
-Group: search by group
-Uid: search by uid
-Gid: search by gid
In the specified time range:
-Atime: [+/-] N (access time): +-Indicates --- (+) ---- N --- (-) ---- currentday
Eg: find-atime-3-exec ls-l {}\;
-Mtime: (modification time) Same as above
-Ctime (change time) Same as above

-Amin is in the same unit as preceding.
-Mmin
-Cmin

-Access closer to anewer a.txt than a.txt
Eg: find-anewer sh01.sh-exec ls-l {}\;
-Newer is equivalent to modification time
-Cnewer is equivalent to change time.
-Type: search by type
D (directory), l (link file), f (common file), s (socket file ),
B (Block device), c (character device), p (command pipeline file)
Eg: find/var-type l-exec ls-l {}\;
-Size: search by size
[+/-] N
-Perm [+/-] mode: Find Permissions
Mode 755
-222 each type of user must match
Eg: find/tmp/myscrip-perm-001
/222 If a user has one type of permissions
-Nouser: No user
For example: find/-nouser to view files without a user name, this file is generally dangerous.
-Nogroup: No group


Search Condition connection:
-A: & generally can be omitted
Eg: find-user root-type f-exec ls-dl {}\;
-O: |
Eg: find-user named-o-type d-exec ls-ld {}\;
-Not or! :!
Eg: find-not \ (-type d-a-user root \)-exec ls-ld {}\;


-Ls-l 'Find/-name passwd'

Wildcard file name: * any character ,? Single character, []
Eg: find/tmp-name a * // search for files starting with

This article is from the "IT dream-qi-sharing" blog

 

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.