ls/dir
Syntax
ls[-r][-a[attrib]][-sfo][file]
Description
Lists the contents of a directory or file information. The
dir
command is an internal alias for this command.
Options
-r
Displays recursively (including subdirectories).
-a attrib
Displays only those files with the attributes specified. If no attributes are specified, all files are listed. If
–a
is not specified, all nonsystem and nonhidden files are listed. The attributes (attrib
) can be one or more of the following:a
—Archives
—Systemh
—Hiddenr
—Read-onlyd
—Directory
-sfo
Displays in standard formatted output.
file
Specifies the name of a file or directory. Wildcards are permitted.
Usage
If no file name or directory name is specified, the current working directory is assumed. The contents of a directory are listed if all the following are true:
Option
-r
is not specified.No wildcard characters are specified in the
file
parameter.- The
file
specified represents an existing directory. In all other cases, the command functions as follows:All files or directories that match the specified name are displayed.
The
-r
option determines whether a recursive search is performed.The option
-a
attrib displays only those files with the attributes specified. If more than one attribute is specified, only the files that have all those attributes are listed. If-a
is followed by nothing, all files or directories are displayed, regardless of their attributes. If-a
itself is not specified, all files, except system and hidden files, are displayed.
Examples
To hide files by adding the hidden or system attribute to them:
fs0:\> attrib +s +h *.efi
ASH fs0:\IsaBus.efi
ASH fs0:\IsaSerial.efi
To display all files and directories, except the files or directories with the
h
or the
s
attribute:
fs0:\> ls
Directory of: fs0:\
06/18/01 09:32p 153 for.nsh
06/18/01 01:02p <DIR> 512 efi
06/18/01 01:02p <DIR> 512 test1
06/18/01 01:02p <DIR> 512 test2
06/18/01 08:04p 29 temp.txt
06/18/01 08:05p <DIR> 512 test
01/28/01 08:24p r 29 readme.txt
3 File(s) 211 bytes
4 Dir(s)
To display files with all attributes in the current directory:
fs0:\> ls -a
Directory of: fs0:\
06/18/01 09:32p 153 for.nsh
06/18/01 01:02p <DIR> 512 efi
06/18/01 01:02p <DIR> 512 test1
06/18/01 01:02p <DIR> 512 test2
06/18/01 10:59p 28,739 IsaBus.efi
06/18/01 10:59p 32,838 IsaSerial.efi
06/18/01 08:04p 29 temp.txt
06/18/01 08:05p <DIR> 512 test
01/28/01 08:24p r 29 readme.txt
5 File(s) 61,788 bytes
4 Dir(s)
To display files with read-only attributes in the current directory:
fs0:\> ls -ar
Directory of: fs0:\
06/18/01 11:14p r 29 readme.txt
1 File(s) 29 bytes
0 Dir(s)
To display files with an attribute of s
:
fs0:\> ls -as isabus.efi
Directory of: fs0:\
06/18/01 10:59p 28,739 IsaBus.efi
1 File(s) 28,739 bytes
0 Dir(s)
To display all in the
fs0:\efi
directory recursively:
fs0:\> ls -r -a efi
To search for files with the specified type in the current directory recursively:
fs0:\> ls -r -a *.efi –b
Output details
The following tables describe possible volume (directory) and file information output from this command.
Column |
Description |
---|---|
Name |
Standard volume label. |
Total Size |
Total number of bytes in the volume. |
Read Only status |
Read-only status as:
|
Free Space |
Total number of free bytes in the volume. |
Block Size |
Nominal block size by which files are typically grown, in bytes. |
Column |
Description |
---|---|
Name |
Complete file name and directory, including the mapped name of the file system. |
Logical Size |
Size of the file, in bytes. |
Physical Size |
Size of the file in the volume, including any padding, in bytes. |
Attributes |
List of file attributes. Possible values are:
|
File Creation Time |
Time when the file was created, in the format
|
File Creation Date |
Date when the file was created, in the format
|
File Access Time |
Time when the file was accessed, in the format
|
File Access Date |
Date when the file was accessed, in the format
|
File Modification Time |
Time when the file was modified, in the format
|
File Modification Date |
Date when the file was modified, in the format
|