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.
--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
- in each of the fields other than the name.
--json option produces machine-readable output similar to
the server api response format.
--replication option adds replication status
--versions option selects all versions of each file, not
just the most recent.
--recursive option will descend into folders, and will select
only files, not folders.
--withWildcard option will allow using
folderName as a greedy wildcard, single character
wildcard and range of characters. It requires the
Remember to quote
folderName to avoid shell expansion.
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"
b2 ls [-h] [--profile PROFILE] [--long] [--json] [--replication] [--versions] [--recursive] [--withWildcard] bucketName [folderName]