Welcome to the upcoming version of the MinIO Documentation! The content on this page is under active development and may change at any time. If you can't find what you're looking for, check our legacy documentation. Thank you for your patience.

mc find

Description

The mc find command supports querying for objects on an S3-compatible host. You can also use the command to search for files on a filesystem.

Units of Measurement

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

k

KB (Kilobyte, 1000 Bytes)

m

MB (Megabyte, 1000 Kilobytes)

g

GB (Gigabyte, 1000 Megabytes)

t

TB (Terrabyte, 1000 Gigabytes)

ki

KiB (Kibibyte, 1024 Bites)

mi

MiB (Mebibyte, 1024 Kibibytes)

gi

GiB (Gibibyte, 1024 Mebibytes)

ti

TiB (Tebibyte, 1024 Gibibytes)

Omitting the suffix defaults to bytes.

Substitution Format

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.

Examples

Find a Specific Object

mc find ALIAS/PATH --name NAME
  • Replace ALIAS with the alias of the S3-compatible host.

  • Replace PATH with the path to a bucket on the S3-compatible host. Omit the path to search from the root of the S3 host.

  • Replace NAME with the object.

Find Objects with File Extention in Bucket

mc find ALIAS/PATH --name *.EXTENSION
  • Replace ALIAS with the alias of the S3-compatible host.

  • Replace PATH with the path to a bucket on the S3-compatible host.

  • Replace EXTENSION with the file extention of the object.

Find All Matching Files and Copy To S3 Service

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 ALIAS with the alias of the S3-compatible host.

  • 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"

Syntax

mc find has the following syntax:

mc find PATH [FLAGS]

find supports the following arguments:

PATH

Required

The full path to search.

For objects on S3-compatible hosts, specify the path to the object as ALIAS/PATH, where:

  • ALIAS is the alias of a configured S3-compatible host, and

  • PATH is the path to the object.

mc find play/mybucket

For files on a filesystem, specify the full filesystem path to the file as PATH:

mc find ~/Documents/

Issuing mc find PATH with no other arguments returns a list of all objects or files at the specified path, similar to mc ls.

--exec

Spawns an external process for each object returned by mc find. Supports substitution formatting of the output.

--ignore

Exclude objects whose names match the specified wildcard pattern.

--name

Return objects whose names match the specified wildcard pattern.

--older

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).

--newer

Mirror object(s) newer than the specified number of days. Specify a string in #d#hh#mm#ss format. For example: --older-than 1d2hh3mm4ss

--path

Return the contents of directories whose names match the specified wildcard pattern.

--print

Prints results to STDOUT. Supports substitution formatting of the output.

--regex

Returns objects or the contents of directories whose names match the specified PCRE regex pattern.

--larger

Match all objects larger than the specified size in units.

--smaller

Match all objects smaller than the specifized size in units.

--maxdepth

Limits directory navigation to the specified depth.

--watch

Continuously monitor the PATH and return any new objects which match the specified criteria.