Linux command find & grep

Linux, like the object is placed at the end of the operation, put the middle parameters

Example: Find [parameters] [path] [Condition] [processed]

find (find qualified files in the directory)

  First of all, Linux in everything is a file. "Finding qualified files in the directory," which is to say the "File" include the so-called Windows directory folder that is

First, the parameters

  -P、-L、-H

Second, the path

  Relative and absolute paths are available.

Third, conditions

1) Find by name

  -name 'a *' to find the beginning of a file

  -iname 'a *' Find names starting with A or a file

  -name '* .txt' Find ending in .txt file

2) Find file type

  -type f Find common file

  -type d find the directory file

  -type l find the linked file

  Find -type b block device file

  -type c Find character device file

  -type p Find pipe file

  Find -type s socket file

3) Find the file according to affiliation

  -user king Find files owned by users king

  -group user1 Find files owned by a group named user1

  -uid 500 looks up the user ID for the user's own files 500

  -gid 0 0 Find a group ID for the user's own files

  -nouser find the file belongs to those who did not

  -nogroup find the file belongs to no group

4) The size of the file used to find [Unit: k, m, g]

  -size 5k find less 5K file

  -size -6k look smaller than the file's 6K

  -size + 2g look larger than 2G file

  -size + 3m -a -size -6m find between 3M to 6M file [-a: and]

  -size + 3k -o -size + 4k find greater than 3K or 6K files between [-o:] or

5) Find according to the time stamp

  atime: the last file to be read or accessed

  mtime: the file was last modified

  ctime: file status change time

  [! ! ! Not a "day" as a unit, but in "24 hours" as the unit]

 

  amin, mmin, cmin [the "minutes" as a unit]

Example:

  24 hours prior find -atime +1 current time ago

  find -atime 24 hours prior to a present time after the previous 48 hours before the current time

  After 24 hours before the current time find -atime -1

  -atime Find 2     before the current time of 2 hours * 24 (48) prior to the current time before 2 hours * 24 24 + (72) after

  48 hours prior to find -atime +2 before the current time

  After 48 hours before the current time find -atime -2

  And so on

 

6) Find under the authority

  find -perm 772 find an exact match of the file permissions to 772

  -perm the Find - 444 Find three types of users have read access to the file

  -perm the Find - file before 774 find two types of users have full control and other users have read access

  -perm Find / 327 as long as the user has a first type of two-readable and executable permissions, or a second type user read permission, or the third user has a writable, readable, executable permissions three either a file will be found

 

grep (search for text in a file and print)

Guess you like

Origin www.cnblogs.com/thousandsofeyes/p/11402978.html