Dir (command)

Shell command for listing files and directories
title: "Dir (command)" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["cp/m-commands", "internal-dos-commands", "microcomputer-software", "microsoft-free-software", "msx-dos-commands", "os/2-commands", "reactos-commands", "windows-commands", "windows-administration"] description: "Shell command for listing files and directories" topic_path: "technology/operating-systems" source: "https://en.wikipedia.org/wiki/Dir_(command)" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Shell command for listing files and directories ::
::data[format=table title="Infobox software"]
| Field | Value |
|---|---|
| name | dir |
| screenshot | SpartaDOS X prompt.png |
| caption | The SpartaDOS X DIR command |
| developer | DEC, DR, Intel, Cromemco, MetaComCo, Microsoft, IBM, Datalight, ICD, Inc. |
| operating system | CP/M, MP/M, ISIS-II, iRMX 86, CDOS, TRIPOS, DOS, MSX-DOS, SISNE plus, 4690 OS, PC-MOS, OS/2, Windows, Singularity, ReactOS, AROS, VMS, RT-11, RSX-11, OS/8, AmigaDOS |
| platform | Cross-platform |
| genre | Command |
| license | CP/M, MP/M: BSD-like |
| MS-DOS: MIT | |
| PC-MOS: GPL-3.0-only | |
| ReactOS: GPL | |
| :: |
| name = dir
| logo =
| screenshot = SpartaDOS X prompt.png
| screenshot size =
| caption = The SpartaDOS X DIR command
| developer = DEC, DR, Intel, Cromemco, MetaComCo, Microsoft, IBM, Datalight, ICD, Inc.
| released =
| latest release version =
| latest release date =
| operating system = CP/M, MP/M, ISIS-II, iRMX 86, CDOS, TRIPOS, DOS, MSX-DOS, SISNE plus, 4690 OS, PC-MOS, OS/2, Windows, Singularity, ReactOS, AROS, VMS, RT-11, RSX-11, OS/8, AmigaDOS
| platform = Cross-platform
| genre = Command
| license = CP/M, MP/M: BSD-like
MS-DOS: MIT
PC-MOS: GPL-3.0-only
ReactOS: GPL
| website =
dir, short for directory, is a shell command for listing file system contents: files and directories. Arguably, the command provides the same essential functionality as the [ls](ls) command, but typically the two commands are described as notably separate concepts, possibly since is implemented from a codebase that shares more history than many implementations.
The command is often implemented as internal in the operating system shell instead of as a separate application as many other commands are.
Variants
::figure[src="https://upload.wikimedia.org/wikipedia/commons/4/44/Abort_Retry_Fail.PNG" caption="Screenshot showing the "[[Abort, Retry, Fail?]]" prompt on [[MS-DOS]]."] ::
Although syntax, semantics and implementations vary, a command with essentially the same functionality is available in the operating systems: CP/M, MP/M, ISIS-II, iRMX 86, CDOS, TRIPOS, DOS, 4690 OS, OS/2, Windows, Singularity, ROM-DOS, ReactOS, GNU, AROS, VMS, RT-11, RSX-11, OS/8, 86-DOS, MS-DOS (in versions 1 and later), and DOSBox.
Some applications also provide a command with similar functionality. The typical File Transfer Protocol (FTP) command-line client provides a dir command for listing a remote directory. The numerical computing environments MATLAB and GNU Octave include a dir
command.
Generally, Unix-like systems use the command for the needs that dir satisfies in other types of systems. Notably, the Unix-like GNU operating system, provides a dir command that is equivalent to ls -C -b; that is, by default files are listed in columns, sorted vertically, and special characters are represented by backslash escape sequences.
Examples
::figure[src="https://upload.wikimedia.org/wikipedia/commons/e/ec/Commodore_C128_CPM_Screenshot_2_full.jpg" caption="[[CP/M 3.0]] directory listing on a [[Commodore 128]] home computer."] ::
::figure[src="https://upload.wikimedia.org/wikipedia/commons/3/30/Robotron1715SCREEN.gif" caption="robotron]] [[PC 1715]]."] ::
::figure[src="https://upload.wikimedia.org/wikipedia/commons/9/9f/J_Elwro_804_Junior.JPG" caption="Directory listing on [[CP/J 2.21]] running on an [[Elwro 804 Junior]]."] ::
::figure[src="https://upload.wikimedia.org/wikipedia/commons/1/10/Dir_command_in_Windows_Command_Prompt.png" caption="Command Prompt]] showing a directory listing."] ::
List all files and directories in the working directory.
List text and batch files of the working directory by specifying filename extensions ".txt" or ".bat" with the "*" wildcard character that matches any base file name.
List files and directories in the specified directory and any subdirectories, recursively, in wide format, pausing after each screen of output. The directory name is enclosed in double-quotes, to prevent it from being interpreted is as two separate command-line options because it contains a space.
List any NTFS junction points:
References
References
- (October 22, 1988). "AmigaDOS quick reference". Grand Rapids, Mi : Abacus.
- "Operating manual". cpm.z80.de.
- Digital Research. (1981-09-25). "MP/M-86 Operating System - User's Guide". [[Digital Research]].
- [http://bitsavers.org/pdf/intel/ISIS_II/9800306-06_ISIS-II_Users_Guide_May81.pdf ISIS II Users Guide]
- [https://archive.org/details/bitsavers_inteliRMX1_19819263 iRMX 86 INTRODUCTION AND OPERATOR'S REFERENCE MANUAL For Release 6]
- [http://www.hartetechnologies.com/manuals/Cromemco/CDOSv1.PDF CDOS USER'S MANUAL]
- "Introduction to Tripos".
- [https://archive.org/details/4690OSV6r2UsersGuide/page/n169]{{Dead link. (October 2019)
- "JaTomes Help - OS/2 Commands".
- "MS-DOS and Windows command line dir command".
- "Datalight ROM-DOS User's Guide".
- (October 22, 2019). "GitHub - reactos/reactos: A free Windows-compatible Operating System".
- "GNU Coreutils Manual". Free Software Foundation.
- "AROS Research Operating System".
- (1980). "86-DOS - Disk Operating System for the 8086 - User's Manual". [[Seattle Computer Products, Inc.]].
- (2003). "Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition". [[Microsoft Press]].
- "List folder contents - MATLAB dir".
- "Function Reference: dir".
- [//www.gnu.org/software/coreutils/manual/html_node/dir-invocation.html dir invocation] (GNU coreutils) at www.gnu.org
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::