Home Explore Blog CI



man-pages

11th chunk of `find.man`
8832d4bc087575a78a92fa64c6db68362976b24abd222a9a0000000100001017
 exactly mode (octal or symbolic).  Since an exact match is required, if you want to use this form for symbolic modes, you may have to specify a rather complex mode string.  For exam‐
              ple ‘-perm g=w’ will only match files which have mode 0020 (that is, ones for which group write permission is the only permission set).  It is more likely that you will want to use the ‘/’ or ‘-’ forms, for ex‐
              ample ‘-perm -g=w’, which matches any file with group write permission.  See the EXAMPLES section for some illustrative examples.

       -perm -mode
              All of the permission bits mode are set for the file.  Symbolic modes are accepted in this form, and this is usually the way in which you would want to use them.  You must specify ‘u’, ‘g’ or ‘o’ if you  use  a
              symbolic mode.  See the EXAMPLES section for some illustrative examples.

       -perm /mode
              Any of the permission bits mode are set for the file.  Symbolic modes are accepted in this form.  You must specify ‘u’, ‘g’ or ‘o’ if you use a symbolic mode.  See the EXAMPLES section for some illustrative ex‐
              amples.  If no permission bits in mode are set, this test matches any file (the idea here is to be consistent with the behaviour of -perm -000).

       -perm +mode
              This is no longer supported (and has been deprecated since 2005).  Use -perm /mode instead.

       -readable
              Matches  files  which  are  readable by the current user.  This takes into account access control lists and other permissions artefacts which the -perm test ignores.  This test makes use of the access(2) system
              call, and so can be fooled by NFS servers which do UID mapping (or root‐squashing), since many systems implement access(2) in the client’s kernel and so cannot make use of the UID mapping  information  held  on
              the server.

       -regex pattern
              File  name  matches  regular  expression pattern.  This is a match on the whole path, not a search.  For example, to match a file named ./fubar3, you can use the regular expression ‘.*bar.’ or ‘.*b.*3’, but not
              ‘f.*r3’.  The regular expressions understood by find are by default Emacs Regular Expressions (except that ‘.’ matches newline), but this can be changed with the -regextype option.

       -samefile name
              File refers to the same inode as name.  When -L is in effect, this can include symbolic links.

       -size n[cwbkMG]
              File uses less than, more than or exactly n units of space, rounding up.  The following suffixes can be used:

              ‘b’    for 512‐byte blocks (this is the default if no suffix is used)

              ‘c’    for bytes

              ‘w’    for two‐byte words

              ‘k’    for kibibytes (KiB, units of 1024 bytes)

              ‘M’    for mebibytes (MiB, units of 1024 * 1024 = 1048576 bytes)

              ‘G’    for gibibytes (GiB, units of 1024 * 1024 * 1024 = 1073741824 bytes)

              The size is simply the st_size member of the struct stat populated by the lstat (or stat) system call, rounded up as shown above.  In other words, it’s consistent with the result you get  for  ls -l.   Bear  in
              mind that the ‘%k’ and ‘%b’ format specifiers of -printf handle sparse files differently.  The ‘b’ suffix always denotes 512‐byte blocks and never 1024‐byte blocks, which is different to the behaviour of -ls.

              The  + and ‐ prefixes signify greater than and less than, as usual; i.e., an exact size of n units does not match.  Bear in mind that the size is rounded up to the next unit.  Therefore -size -1M is not equiva‐
              lent to -size -1048576c.  The former only matches empty files, the latter matches files from 0 to 1,048,575 bytes.

       -true  Always true.

       -type c
              File is of type c:

              b      block (buffered) special

              c      character (unbuffered) special

Title: find Tests: -perm (continued), -readable, -regex, -samefile, -size, -true, -type
Summary
This section details the `-perm` tests, showing how to check for specific permission bits using octal or symbolic modes. It covers `-readable` (files readable by the current user), `-regex` (filename matches regular expression), `-samefile` (refers to the same inode), `-size` (file size in specified units), `-true` (always true), and `-type` (file type, e.g., block special, character special).