linux--File Lookup

Source: Internet
Author: User

Let i=$[$I +1]

sum=$[$SUM + $I]

Let sum+= $I

Let i+=1 equivalent to let i++

-=

Let i-=1 equivalent to let i--

grep, Egrep, Fgrep: Text lookup

File Lookup:

Locate:

Non-real-time, fuzzy matching, lookup is based on the system-wide file database;

# UpdateDB, manually generate the file database

Fast speed

Find:

Realtime

Accurate

Support for many search criteria

Traverse all files in the specified directory to complete the lookup, slow;

Find Find Path Lookup criteria finds a later processing action

Find the path: The default is the current directory

Lookup criteria: Default to all files under the specified path

Handling actions: Default to display to screen

Matching Criteria:

-name ' FILENAME ': exact matching of file masterpieces

File name wildcard:

*: Any character of any length

?

[]

-iname ' filename ': file name matching is case insensitive

-regex PATTERN: File name matching based on regular expressions

-user USERNAME: Based on owner Lookup

-group GROUPNAME: Search by Genus Group

-uid UID: Search by UID

-gid GID: Search by GID

-nouser: Finding files that are not owned by the master

-gid GID: Find files that are not owned by a group

-type

F: Normal file

D; Directory

C: Character device

B: Block device

L: Link File

P: Piping Equipment

S: Socket

# Find/tmp-type S

-size [+|-]

#k

#M

#G

Combination conditions:

-A and

-O or

-not Non-

/tmp directory, not a directory, and a file that is not a socket type

Find/tmp-not-type d-a-not Type S

Or

Find/tmp-not \ (-type d-o-type s\)

/tmp/test directory, the owner is not user1, nor user2 files;

Find/tmp/test-not-user user1-a-not-user User2

Or

Find/tmp/test-not \ (-user user1-o-user user2\)

-mtime

-ctime

-atime

[+|-]#

-mmin

-cmin

-amin

[+|-]#

-perm MODE: Exact match

/mode: Any one match that satisfies the condition

-mode: File permissions can fully contain this MODE only when the condition is met

Action:

-print: Display

-ls: Displays the details of each file in a form similar to Ls-l

-ok COMMAND {} \; User confirmation is required for each operation

-exec COMMAND {} \;

# find/etc-perm-006-exec chmod o-w {} \;

Practice:

1. Find all files in the/var directory under the master root and belong to the group mail;
# Find/var-user root-a-group Mail

2. Find files that do not belong to Root,bin or student in the/USR directory;
# find/usr-not-user root-a-not-user bin-a-not-user Student

3. Find files that have been modified in the last week and not belonging to root and student users in/etc directory;

# find/etc-mtime-7-a-not-user root-a-not-user Student
4, find the current system does not belong to the main or the group and the last 1 days have been visited the files, and the main group are modified to root;
# Find/\ (-nouser-o-nogroup\)-a-atime-1-exec chown root:root {} \;

5. Find files larger than 1M in/etc directory and write their filenames to/tmp/etc.largefiles files;

# find/etc-size +1m >>/tmp/etc.largefiles

# Find/etc-size +1m-exec Echo {} >>/tmp/etc.largefiles \;

# find/etc-size +1m-xargs >>/tmp/etc.largefiles

6, look for all the users in/etc directory do not have permission to write files, display its detailed information;
# Find/etc-not-perm/222-ls

linux--File Lookup

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.