This topic describes how to run the cat command to view the content of the specified object in a bucket.
Usage notes
-
To view object content, you must have the
oss:GetObjectpermission. For more information, see Grant a custom policy. -
For ossutil 1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. For ossutil earlier than 1.6.16, you need to update the binary name based on the operating system. For more information, see ossutil command reference.
Command syntax
ossutil cat oss://bucketname/objectname [--payer <value>] [--version-id <value>]
We recommend that you run this command to view TXT content.
The following table describes the preceding parameters.
|
Parameter |
Description |
|
bucketname |
The name of the bucket. |
|
objectname |
The name of the object. |
|
--payer |
The payer of the request. If you want the requester who accesses the resources in the specified path to pay the fees that are generated by the operation, such as traffic and request fees, set this parameter to requester. |
|
--version-id |
The version ID of the object. This parameter applies only to a versioning-enabled or versioning-suspended bucket. |
Examples
-
View the content of the test.txt object in the examplebucket bucket for which versioning is not enabled.
ossutil cat oss://examplebucket/test.txtThe 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.
ossutil cat oss://examplebucket/exampleobject.txt --version-id CAEQARiBgID8rumR2hYiIGUyOTAyZGY2MzU5MjQ5ZjlhYzQzZjNlYTAyZDE3****For more information about how to query all versions of an object, see ls (List buckets, objects, or parts).
The following output indicates the content of the 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 access a bucket in a different region, use -e to specify the endpoint. To access a bucket owned by a different Alibaba Cloud account, use -i for the AccessKey ID and -k for the AccessKey secret.
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:
ossutil cat oss://examplebucket1/exampleobject1.txt -e oss-cn-shanghai.aliyuncs.com -i yourAccessKeyID -k yourAccessKeySecret