Dir (command)

{{Short description|Shell command for listing files and directories}}

{{Other uses|Dir (disambiguation)}}

{{Lowercase title}}

{{Infobox software

| 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.{{cite book|url=http://archive.org/details/1988-rugheimer-spanik-amigados-quick-reference|title=AmigaDOS quick reference|first1=Hannes|last1=Rügheimer|first2=Christian|last2=Spanik|date=October 22, 1988|publisher=Grand Rapids, Mi : Abacus|isbn=9781557550491|via=Internet Archive}} Arguably, the command provides the same essential functionality as the ls command, but typically the two commands are described as notably separate concepts, possibly since {{code|ls}} is implemented from a codebase that shars more history than many {{code|dir}} implementations.

The command is often implemented as internal in the operating system shell instead of as a separate application as many other commands are.

Implementations

File:Abort Retry Fail.PNG" prompt on MS-DOS.]]

Although syntax, semantics and implementations vary, a {{code|dir}} command is available in the command-line interface (CLI) of the operating systems Digital Research CP/M,{{cite web|url=http://www.cpm.z80.de/manuals/cpm22-m.pdf |title=Operating manual |publisher=cpm.z80.de |access-date=2019-10-22}} MP/M,{{cite book |author=Digital Research |author-link=Digital Research |title=MP/M-86 Operating System - User's Guide |date=1981-09-25 |edition=1 |publisher=Digital Research |location=Pacific Grove, CA, USA |url=http://bitsavers.informatik.uni-stuttgart.de/pdf/digitalResearch/mpm-86/MPM-86_Users_Guide_Sep81.pdf |access-date=2017-01-04 |url-status=live |archive-url=https://web.archive.org/web/20170104172228/http://bitsavers.informatik.uni-stuttgart.de/pdf/digitalResearch/mpm-86/MPM-86_Users_Guide_Sep81.pdf |archive-date=2017-01-04}} Intel ISIS-II,[http://bitsavers.org/pdf/intel/ISIS_II/9800306-06_ISIS-II_Users_Guide_May81.pdf ISIS II Users Guide] iRMX 86,[https://archive.org/details/bitsavers_inteliRMX1_19819263 iRMX 86 INTRODUCTION AND OPERATOR'S REFERENCE MANUAL For Release 6] Cromemco CDOS,[http://www.hartetechnologies.com/manuals/Cromemco/CDOSv1.PDF CDOS USER'S MANUAL] MetaComCo TRIPOS,{{cite web|url=https://www.pagetable.com/docs/amigados_tripos/tripos_manuals.pdf |title=Introduction to Tripos |access-date=2019-10-22}} DOS, IBM/Toshiba 4690 OS,[https://archive.org/details/4690OSV6r2UsersGuide/page/n169]{{Dead link|date=October 2019}} IBM OS/2,{{cite web|url=http://www.jatomes.com/Help/Os2Cmd.php#DIR|title=JaTomes Help - OS/2 Commands|website=www.jatomes.com|access-date=2019-07-20|archive-date=2019-04-14|archive-url=https://web.archive.org/web/20190414130029/http://www.jatomes.com/Help/Os2Cmd.php#DIR|url-status=dead}} Microsoft Windows,{{cite web|url=https://www.computerhope.com/dirhlp.htm|title=MS-DOS and Windows command line dir command|website=www.computerhope.com}} Singularity, Datalight ROM-DOS,{{Cite web|url=https://www.datalight.com/assets/files/ROM-DOS_Users_Guide.pdf|title=Datalight ROM-DOS User's Guide|website=www.datalight.com}} ReactOS,{{cite web|url=https://github.com/reactos/reactos|title=GitHub - reactos/reactos: A free Windows-compatible Operating System|date=October 22, 2019|via=GitHub}} GNU,{{cite web|url=https://www.gnu.org/software/coreutils/dir|title=GNU Coreutils Manual|publisher=Free Software Foundation}} AROS{{cite web|url=http://aros.sourceforge.net/documentation/users/shell/index.php|title=AROS Research Operating System|website=aros.sourceforge.net}} and in the DCL command-line interface used on DEC VMS, RT-11 and RSX-11. It is also supplied with OS/8 as a CUSP (Commonly-Used System Program).

The dir command is supported by Tim Paterson's SCP 86-DOS.{{cite book |title=86-DOS - Disk Operating System for the 8086 - User's Manual |edition=Preliminary |version=Version 0.3 |date=1980 |publisher=Seattle Computer Products, Inc. |location=Seattle, Washington, USA |url=http://www.patersontech.com/Dos/docs/86_Dos_usr_03.pdf |access-date=2019-07-14 |url-status=dead |archive-url=https://web.archive.org/web/20190714004434/http://www.patersontech.com/dos/docs/86_Dos_usr_03.pdf |archive-date=2019-07-14}} (59 pages) On MS-DOS, the command is available in versions 1 and later.{{Cite book|author-last=Wolverton|author-first=Van|title=Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition|date=2003|publisher=Microsoft Press|isbn=0-7356-1812-7}} It is also available in the open source MS-DOS emulator DOSBox. MS-DOS prompts "Abort, Retry, Fail?" after being commanded to list a directory with no diskette in the drive.

The numerical computing environments MATLAB and GNU Octave include a dir

function with similar functionality.{{cite web|url=https://www.mathworks.com/help/matlab/ref/dir.html|title=List folder contents - MATLAB dir|website=www.mathworks.com}}{{cite web|url=https://octave.sourceforge.io/octave/function/dir.html|title=Function Reference: dir|website=octave.sourceforge.io}}

Examples

=DOS, Windows, ReactOS=

List all files and directories in the current working directory.

{{sxhl|2=doscon|C:\Users>dir}}

List any text files and batch files (filename extension ".txt" or ".bat").

{{sxhl|2=doscon|C:\Users>dir *.txt *.bat}}

Recursively list all files and directories in the specified directory and any subdirectories, 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 whitespace character.

{{sxhl|2=doscon|C:\Users>dir /s /w /p "C:\Users\johndoe\My Documents"}}

List any NTFS junction points:

{{pre|

{{codett|2=doscon|C:\Users>dir /ash}}

{{codett|2=output|Volume in drive C is OS.}}

{{codett|2=output|Volume Serial Number is xxxx-xxxx}}

{{codett|2=output|Directory of C:\Users}}

{{codett|2=output|12/07/2019 02:30 AM All Users [C:\ProgramData]}}

{{codett|2=output|12/07/2019 02:30 AM Default User [C:\Users\Default]}}

{{codett|2=output|12/07/2019 02:12 AM 174 desktop.ini}}

{{codett|2=output|1 File(s) 174 bytes}}

{{codett|2=output|2 Dir(s) 332,659,789,824 bytes free}}

}}

=Unix=

Traditionally, Unix and Unix-like systems use the {{code|ls}} command for the needs that dir satisfies. But, the GNU operating system, has 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".[//www.gnu.org/software/coreutils/manual/html_node/dir-invocation.html dir invocation] (GNU coreutils) at www.gnu.org Actually, for compatibility reasons, {{code|ls}} produces device-dependent output. The dir command, on the other hand, produces device-independent output.

See also

References

{{Reflist}}

Further reading

  • {{Cite book|author-last=Wolverton|author-first=Van|title=MS-DOS Commands: Microsoft Quick Reference, 4th Revised edition|url=https://archive.org/details/msdos00wolv|url-access=registration|date=1990|publisher=Microsoft Press|isbn=978-1556152894}}
  • {{Cite book|author1=Kathy Ivens|author2=Brian Proffit|year=1993|title=OS/2 Inside & Out|publisher=Osborne McGraw-Hill|isbn=978-0078818714}}
  • {{Cite book|first=Æleen|last=Frisch|year=2001|title=Windows 2000 Commands Pocket Reference|publisher=O'Reilly|isbn=978-0-596-00148-3}}