Ls command

Using the file naming convention that / separates folder names from their contents, returns a list of the files and folders in a given folder. If no folder name is given, lists all files at the top level.

The --long option produces very wide multi-column output showing the upload date/time, file size, file id, whether it is an uploaded file or the hiding of a file, and the file name. Folders don’t really exist in B2, so folders are shown with - in each of the fields other than the name.

The --json option produces machine-readable output similar to the server api response format.

The --replication option adds replication status

The --versions option selects all versions of each file, not just the most recent.

The --recursive option will descend into folders, and will select only files, not folders.

The --withWildcard option will allow using *, ? and `[]` characters in folderName as a greedy wildcard, single character wildcard and range of characters. It requires the --recursive option. Remember to quote folderName to avoid shell expansion.

Examples

Note

Note the use of quotes, to ensure that special characters are not expanded by the shell.

List csv and tsv files (in any directory, in the whole bucket):

b2 ls --recursive --withWildcard bucketName "*.[ct]sv"

List all info.txt files from buckets bX, where X is any character:

b2 ls --recursive --withWildcard bucketName "b?/info.txt"

List all pdf files from buckets b0 to b9 (including sub-directories):

b2 ls --recursive --withWildcard bucketName "b[0-9]/*.pdf"

Requires capability:

  • listFiles

b2 ls [-h] [--profile PROFILE] [--long] [--json] [--replication] [--versions]
      [--recursive] [--withWildcard]
      bucketName [folderName]

Positional Arguments

bucketName
folderName

Named Arguments

--profile
--long

Default: False

--json

Default: False

--replication

Default: False

--versions

Default: False

--recursive

Default: False

--withWildcard

Default: False