mc head

Syntax

The mc head command displays the first n lines of an object, where n is an argument specified to the command.

mc head does not perform any transformation or formatting of object contents to facilitate readability. You can also use mc head against the local filesystem to produce similar results to the head commandline tool.

The following command returns the first 10 lines of an object in the mydata bucket on the myminio MinIO deployment:

mc head myminio/mydata/myobject.txt

The command has the following syntax:

mc [GLOBALFLAGS] head                     \
                 [--lines int]            \
                 [--rewind "string"]      \
                 [--version-id "string"]  \
                 [--encrypt-key "string"] \
                 ALIAS [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.

Parameters

ALIAS

Required The object or objects to print.

For an object on MinIO, specify the alias and the full path to that object (e.g. bucket and path to object). For example:

mc head play/mybucket/object.txt

You can specify multiple objects on the same or different MinIO deployments. For example:

mc head ~/mydata/object.txt myminio/mydata/object.txt

For an object on a local filesystem, specify the full path to that object. For example:

mc head ~/mydata/object.txt
--lines, n

Optional The number of lines to print.

Defaults to 10.

--encrypt-key

Optional Encrypt or decrypt objects using server-side encryption with client-specified keys. Specify key-value pairs as KEY=VALUE.

  • Each KEY represents a bucket or object.

  • Each VALUE represents the data key to use for encrypting

    object(s).

Enclose the entire list of key-value pairs passed to --encrypt-key in double quotes ".

--encrypt-key can use the MC_ENCRYPT_KEY environment variable for retrieving a list of encryption key-value pairs as an alternative to specifying them on the command line.

--rewind

Optional Directs mc head to operate only on the object version(s) that existed at specified point-in-time.

  • To rewind to a specific date in the past, specify the date as an ISO8601-formatted timestamp. For example: --rewind "2020.03.24T10:00".

  • To rewind a duration in time, specify the duration as a string in #d#hh#mm#ss format. For example: --rewind "1d2hh3mm4ss".

--rewind requires that the specified ALIAS be an S3-compatible service that supports Bucket Versioning. For MinIO deployments, use mc version to enable or disable bucket versioning.

--version-id, vid

Optional Directs mc head to operate only on the specified object version.

--version-id requires that the specified ALIAS be an S3-compatible service that supports Bucket Versioning. For MinIO deployments, use mc version to enable or disable bucket versioning.

Global Flags

--debug
Optional

Enables verbose output to the console.

For example:

mc --debug COMMAND
--config-dir
Optional

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.

--JSON
Optional

Enables JSON lines formatted output to the console.

For example:

mc --JSON COMMAND
--no-color
Optional

Disables the built-in color theme for console output. Useful for dumb terminals.

--quiet
Optional

Suppresses console output.

--insecure
Optional

Disables TLS/SSL certificate verification. Allows TLS connectivity to servers with invalid certificates. Exercise caution when using this option against untrusted S3 hosts.

--version
Optional

Displays the current version of mc.

--help
Optional

Displays a summary of command usage on the terminal.

Examples

View Partial Contents of an Object

Use mc head to return the first 10 lines of an object:

mc head ALIAS/PATH
  • Replace ALIAS with the alias of the S3-compatible host.

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

View Partial Contents of an Object at a Point in Time

Use mc head --rewind to return the first 10 lines of the object at a specific point-in-time in the past:

mc head ALIAS/PATH --rewind DURATION
  • Replace ALIAS with the alias of the S3-compatible host.

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

  • Replace DURATION with the point-in-time in the past at which the command returns the object. For example, specify 30d to return the version of the object 30 days prior to the current date.

Requires Versioning

mc head requires bucket versioning to use this feature. Use mc version to enable versioning on a bucket.

View Partial Contents of an Object with Specific Version

Use mc head --version-id to return the first 10 lines of the object at a specific point-in-time in the past:

mc head ALIAS/PATH --version-id VERSION
  • Replace ALIAS with the alias of the S3-compatible host.

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

  • Replace VERSION with the version of the object. For example, specify 30d to return the version of the object 30 days prior to the current date.

Requires Versioning

mc head requires bucket versioning to use this feature. Use mc version to enable versioning on a bucket.

Behavior

S3 Compatibility

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.