tencent cloud

Feedback

Querying Bucket/Object List - ls

Last updated: 2022-05-09 14:18:32

    The ls command is used to query the list of buckets, objects in a bucket, and objects in a directory.

    Command Syntax

    ./coscli ls [cos://bucketAlias[/prefix/]] [flag]
    
    Note:

    ls includes the following optional parameters:

    Parameter Format Description Example
    cos://bucketAlias Specifies a bucket. cos://bucket1
    /prefix/ Specifies a directory. /picture/

    ls includes the following optional flags:

    Flag Abbreviation Flag Name Description
    None --include Includes specific objects.
    None --exclude Excludes specific objects.
    -r --recursive Specifies whether to traverse directories recursively and list all objects.
    Note:

    • --include and --exclude support standard regular expressions. You can use regular expressions to filter objects that meet your requirements.
    • When using zsh, you may need to add double quotes at both ends of the pattern string.
    ./coscli ls cos://bucket1 -r --include ".*.mp4"
    

    Examples

    Listing all buckets of the current account

    ./coscli ls
    

    Listing objects

    Listing all objects in the bucket1 bucket

    ./coscli ls cos://bucket1
    

    Listing all objects and subdirectories in the picture directory in the bucket1 bucket

    ./coscli ls cos://bucket1/picture/
    

    Listing all objects in the picture directory in the bucket1 bucket recursively

    ./coscli ls cos://bucket1/picture/ -r
    

    Listing all MP4 objects in the bucket1 bucket recursively

    ./coscli ls cos://bucket1 -r --include .*.mp4
    

    Listing all non-MP4 objects in the bucket1 bucket recursively

    ./coscli ls cos://bucket1 -r --exclude .*.mp4
    

    Listing all non-JPG objects prefixed with test in the picture directory in the bucket1 bucket

    ./coscli ls cos://bucket1/picture -r --include ^picture/test.* --exclude .*.jpg
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support