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 head

Description

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.

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.

Syntax

head has the following syntax:

mc head [FLAGS] SOURCE [SOURCE...]

head supports the following arguments:

--lines, -n

The number of lines to print.

Defaults to 10.

SOURCE

REQUIRED

The object or objects to print. You can specify both local paths and S3 paths using a configured S3 service alias.

For example:

mc head play/mybucket/object.txt ~/localfiles/mybucket/object.txt
--rewind

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 --SOURCE be an S3-compatible service that supports Bucket Versioning. For MinIO deployments, use mc version to enable or disable bucket versioning.

--version-id, --vid

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

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

--encrypt-key

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.