This topic describes how to run the cat command to view the content of a specified object in a bucket.

Notice Sample command lines in this topic are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. For more information, see ossutil.

Command syntax

./ossutil64 cat oss://bucketname/objectname [--payer <value>] [--version-id <value>]
Notice We recommend that you run this command to view only the content of a TXT object.

The following table describes the parameters that you can configure when you run this command.

Parameter Description
bucketname Specifies the name of the bucket.
objectname Specifies the name of the object.
--payer Specifies the payer of the traffic and request fees charged to view the content of the object. If you want the requester who accesses the resources in the specified path to pay for the traffic and request fees charged during queries, set this parameter to requester.
--version-id Specifies the ID of the specified version of the object. This parameter applies only to objects in buckets for which versioning is enabled or suspended.

Examples

  • View the content of the test.txt object in the examplebucket bucket for which versioning is not enabled.
    ./ossutil64 cat oss://examplebucket/test.txt

    The following output indicates the content of the test.txt object and the time it took to return the output:

    My Website Home Page.
    
    0.088092(s) elapsed
  • View the content of the exampleobject.txt object in the examplebucket bucket for which versioning is enabled.
    ./ossutil64 cat oss://examplebucket/exampleobject.txt --version-id  CAEQARiBgID8rumR2hYiIGUyOTAyZGY2MzU5MjQ5ZjlhYzQzZjNlYTAyZDE3****

    For more information about how to query all versions of an object, see ls.

    The following output indicates the content of a specified version of the test.txt object and the time it took to return the output:

    Hello World.
    
    0.044820(s) elapsed

Common options

To use ossutil to manage buckets that are located in different regions, you can use the -e option to switch to the endpoint of the specified bucket. To use ossutil to manage buckets that are owned by different Alibaba Cloud accounts, you can use the -i option to use the AccessKey ID of the specified account, and use the -k option to use the AccessKey secret of the specified account.

For example, if you want to view the content of the exampleobject1.txt object in the examplebucket1 bucket that belongs to another Alibaba Cloud account in the China (Shanghai) region, you can run the following command:
./ossutil64 cat oss://examplebucket1/exampleobject1.txt -e oss-cn-shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA****  -k 67DLVBkH7EamOjy2W5RVAHUY9H****

For more information about other common options of cat, see Common options.