DC - Find files

# 2.2. Find files

## Content

1. Searching for files with specific attributes
2. Advanced patterns
3. Examples

## 1. Searching for files with specific attributes.

To search for specific attributes you must enter a string pattern, which specifies which attributes are searched for, and if they should be enabled or disabled.

A single attribute is represented with the following format:

`<attribute>+` or `<attribute>-`

The plus sign means that the file must have that attribute set, a minus sign means that the file must not have that attribute set.

The various `<attribute>` identifiers are as follows:

Attributes in Windows
Attribute letter | What it stands for
--- | ---
r | read only
a | archive
h | hidden
s | system
d | directory
l | symlink
t | temporary
p | sparse
c | compressed
e | encrypted

Attributes in Unix/Linux (Permissions)
Permissions letters | What it stands for
--- | ---
ur | user read
uw | user write
ux | user execute
gr | group read
gw | group write
gx | group execute
or | others read
ow | others write
ox | others execute
us | set user ID
gs | set group ID
sb | sticky bit

Attributes in Unix/Linux (File Types)
File Types letters | What it stands for
--- | ---
b | block
c | character
d | directory
f | fifo
l | symlink
r | regular
s | socket

In Unix/Linux you may also use octal representation of permissions. For example 0750 is the same as `ur`, `uw`, `ux`, `gr` and `gx` combined.

(back to top)

## 2. Advanced patterns

Several attributes may be combined together with an AND relationship.

Just specify one pattern after another.

For example: `r+s+h+` matches files that have all three: read-only, hidden and system attributes set.

Furthermore, such groups of AND attributes may be combined together with an OR relationship.

This is done by using the "|" character (vertical bar). For example: `r+|s+h+` matches files that have either:

- read-only attribute set
- both hidden and system attributes set.

It is possible to negate AND sequences using "!" character specified at the start of the sequence.

For example: `!r+s+h+` matches files that don't have all three: read-only, hidden and system attributes set.

The matched file may have none, one or more of those attributes set, but not all of them.

Negation only applies to AND sequences, thus pattern `!r+|!s+h+` matches files that either:

- don't have read-only attribute set (the same as `r-`)
- don't have both hidden and system attributes set.

You cannot use parenthesis to separate sequences.

(back to top)

## 3. Examples

Example in Windows
Examples letters | How it is interpreted
--- | ---
a+s-h- | matches files that have archive attribute set and don't have neither system nor hidden attributes set
e+|c+ | matches files that are either compressed or encrypted (these are NTFS attributes)
d- | matches files but not directories

Example in Unix/Linux
Examples letters | How it is interpreted
--- | ---
uw+|gw+|ow+ | matches files that are writeable either by user, group or anybody else
222+ | matches files that are writeable by user, and by group, and by anybody else
d+ox+ | matches directories that are accessible by anybody
!700+ | matches files that are not fully accessible to the user

(back to top)