mc find
Table of Contents
The mc find
command supports searching for objects on a MinIO
deployment. You can also use the command to search for files on a filesystem.
The following command searches for all objects matching the specified
pattern in the mydata
bucket on the myminio
MinIO deployment:
mc find myminio/mydata --name "*.jpg"
The command has the following syntax:
mc [GLOBALFLAGS] find \
[--exec "string"] \
[--ignore "string"] \
[--larger "string"] \
[--maxdepth "string"] \
[--name "string"] \
[--newer-than "string"] \
[--older-than "string"] \
[--path "string"] \
[--print "string"] \
[--regex "string"] \
[--smaller "string"] \
[--watch] \
ALIAS
Brackets []
indicate optional parameters.
Parameters sharing a line are mutually dependent.
Parameters seperated using the pipe |
operator are mutually exclusive.
Copy the example to a text editor and modify as-needed before running the command in the terminal/shell.
Required
For objects on MinIO or an S3-compatible host, specify the alias and the full path to search (e.g. bucket and prefixes). For example:
mc find play/mydata/
For objects on a filesyste, specify the full path to search. For example:
mc find ~/mydata/
Issuing mc find ALIAS
with no other arguments returns a list of
all objects or files at the specified path, similar to mc ls
.
Optional Spawns an external process for each object returned by
mc find
. Supports substitution formatting of the output.
Optional Match all objects larger than the specified size in units.
Optional Mirror object(s) newer than the specified number of days. Specify
a string in #d#hh#mm#ss
format. For example: --older-than 1d2hh3mm4ss
Optional Mirror object(s) older than the specified time limit. Specify a
string in #d#hh#mm#ss
format. For example: --older-than 1d2hh3mm4ss
Defaults to 0
(all objects).
Optional Return the contents of directories whose names match the specified wildcard pattern.
Optional Prints results to STDOUT
. Supports
substitution formatting of the output.
Optional Returns objects or the contents of directories whose names match the specified PCRE regex pattern.
Optional Match all objects smaller than the specifized size in units.
Optional Continuously monitor the ALIAS
and return any
new objects which match the specified criteria.
The path to a JSON
formatted configuration file that
mc uses for storing data. See Configuration File for
more information on how mc uses the configuration file.
Enables JSON lines formatted output to the console.
For example:
mc --JSON COMMAND
Disables TLS/SSL certificate verification. Allows TLS connectivity to servers with invalid certificates. Exercise caution when using this option against untrusted S3 hosts.
Displays the current version of mc
.
mc find ALIAS/PATH --name NAME
mc find ALIAS/PATH --name *.EXTENSION
Use mc find
with the --exec
option to find
files on a local filesystem and pass them to an mc command for
further processing. The following example uses mc cp
to copy the
output of mc find
to an S3-compatible host.
mc find FILEPATH --name "*.EXTENSION" --exec "mc cp {} ALIAS/PATH"
Replace FILEPATH
with the full file path to the
directory to search.
Replace EXTENSION
with the file extention of the
object.
Replace PATH
with the path to a bucket on the
S3-compatible host.
To continuously watch the specified directory and copy new objects,
include the --watch
argument:
mc find --watch FILEPATH --name "*.EXTENSION" --exec "mc cp {} ALIAS/PATH"
The mc find --smaller
and mc find --larger
flags
accept the following case-insensitive suffixes to represent the unit of the
specified size value:
Suffix |
Unit Size |
---|---|
|
KB (Kilobyte, 1000 Bytes) |
|
MB (Megabyte, 1000 Kilobytes) |
|
GB (Gigabyte, 1000 Megabytes) |
|
TB (Terrabyte, 1000 Gigabytes) |
|
KiB (Kibibyte, 1024 Bites) |
|
MiB (Mebibyte, 1024 Kibibytes) |
|
GiB (Gibibyte, 1024 Mebibytes) |
|
TiB (Tebibyte, 1024 Gibibytes) |
Omitting the suffix defaults to bytes
.
The mc find --exec
and mc find --print
commands
support string substitutions with special interpretations for following
keywords.
The following keywords are supported for both filesystem and S3 service targets:
{}
- Substitutes to full path.
{base}
- Substitutes to basename of path.
{dir}
- Substitutes to dirname of the path.
{size}
- Substitutes to object size of the path.
{time}
- Substitutes to object modified time of the path.
The following keyword is supported only for S3 service targets:
{url}
- Substitutes to a shareable URL of the path.
The mc commandline tool is built for compatibility with the AWS S3 API and is tested MinIO and AWS S3 for expected functionality and behavior.
MinIO provides no guarantees for other S3-compatible services, as their S3 API implementation is unknown and therefore unsupported. While mc commands may work as documented, any such usage is at your own risk.
This work is licensed under a Creative Commons Attribution 4.0 International License.
©2020-Present, MinIO, Inc.