dir (command)
In computing, dir
(directory) is a command used for file and directory listing, specifically in the command line interface (CLI) of the operating systems CP/M, DOS, OS/2, Singularity, Microsoft Windows and in the DCL command line interface used
on VMS, RT-11 and RSX-11. The command is also supplied with OS/8 as a CUSP (Commonly-Used System Program).
Sample usage
The following example demonstrates the output of the dir command on Windows 7, without arguments:
C:\Users\Public\Pictures\Sample Pictures>dir
Volume in drive C is System
Volume Serial Number is C8D0-76E2
Directory of C:\Users\Public\Pictures\Sample Pictures
14-07-2009 06:41 <DIR> .
14-07-2009 06:41 <DIR> ..
14-07-2009 06:52 879,394 Chrysanthemum.jpg
14-07-2009 06:52 845,941 Desert.jpg
14-07-2009 06:52 595,284 Hydrangeas.jpg
14-07-2009 06:52 775,702 Jellyfish.jpg
14-07-2009 06:52 780,831 Koala.jpg
14-07-2009 06:52 561,276 Lighthouse.jpg
14-07-2009 06:52 777,835 Penguins.jpg
14-07-2009 06:52 620,888 Tulips.jpg
8 File(s) 5,837,151 bytes
2 Dir(s) 57,925,980,160 bytes free
C:\Users\Public\Pictures\Sample Pictures>dir /w
Volume in drive C is System
Volume Serial Number is C8D0-76E2
Directory of C:\Users\Public\Pictures\Sample Pictures
[.] [..] Chrysanthemum.jpg Desert.jpg Hydrangeas.jpg Jellyfish.jpg
Koala.jpg Lighthouse.jpg Penguins.jpg Tulips.jpg
8 File(s) 5,837,151 bytes
2 Dir(s) 57,925,992,448 bytes free
C:\Users\Public\Pictures\Sample Pictures>
Options/Switches
C:\>HELP DIR
DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
[drive:][path][filename]
Specifies drive, directory, and/or files to list.
/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files I Not content indexed files
L Reparse Points - Prefix meaning not
/B Uses bare format (no heading information or summary).
/C Display the thousand separator in file sizes. This is the
default. Use /-C to disable display of separator.
/D Same as wide but files are list sorted by column.
/L Uses lowercase.
/N New long list format where filenames are on the far right.
/O List by files in sorted order.
sortorder N By name (alphabetic) S By size (smallest first)
E By extension (alphabetic) D By date/time (oldest first)
G Group directories first - Prefix to reverse order
/P Pauses after each screenful of information.
/Q Display the owner of the file.
/R Display alternate data streams of the file.
/S Displays files in specified directory and all subdirectories.
/T Controls which time field displayed or used for sorting timefield.
C Creation
A Last Access
W Last Written
/W Uses wide list format.
/X This displays the short names generated for non-8dot3 file names. The format is that of /N with the
name inserted before the long name. If no short name is present, blanks are displayed in its place.
/4 Displays four-digit years.
Switches may be present in the DIRCMD environment variable. Override preset switches by prefixing any switch with - (hyphen) -- for example, /-W. [1]
Unices
dir
is not a Unix command, Unix has the analogous ls
command instead. The Linux operating system, however, 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," as the documentation says.[2]
See also
- Directory (OpenVMS command)
- List of DOS commands
- ls (corresponding command for *nix systems)
References
- ↑ Windows 7
- ↑ dir invocation (GNU coreutils) at www.gnu.org