Skip to content

dir

list directory contents

NAME
    dir - list directory contents

SYNOPSIS
    dir [-R] [-S] [path | glob | file]

DESCRIPTION
    Lists a directory. With no argument it lists the current working
    directory; a path lists that directory; a glob (containing * or ?)
    lists the matching entries; and a single file lists just that file's
    row (like `ls file`). A name that matches nothing prints "dir: not
    found". Directories are shown with a trailing slash. dir is a /bin
    program.

    Entries are sorted within each directory (and, with -R, at every
    level). The default order is by name, raw ASCII -- so uppercase
    A-Z sort before lowercase a-z. -S sorts by byte size, largest
    first, with ties broken by name; a directory has no shown size and
    so counts as size 0, sorting after all files.

OPTIONS
    -R    list subdirectories recursively (like tree)
    -S    sort by file size, largest first (default is by name)

LIMITS
    With -R, descends at most 16 levels and buffers 64 entries per
    level; beyond that the listing is silently truncated. A glob
    pattern is capped at 15 characters.

EXAMPLES
    dir              list the current directory, sorted by name
    dir /bin         list a directory by path
    dir -S           list the CWD, largest files first
    dir *.asm        entries in the CWD matching a glob
    dir /bin/*.bin   glob within another directory
    dir README.TXT   list a single file's row (like ls)
    dir -R /sub      recursive listing of /sub
    dir -R -S /sub   recursive listing, each level size-sorted

SEE ALSO
    tree, find, cd, pwd, ls

See also: tree, find, cd, pwd

The text of man dir on P8X (os/man/dir in the repository). All commands