ls command (lists the contents of files or directories)
- Organization of this page
Format
ls [-1] [-A] [-a] [-C] [-c] [-d] [-F] [-f] [-g] [-h] [-i] [-k] [-L] [-l] [-m] [-n] [-p] [-q] [-R] [-r] [-S] [-s] [-T] [-t] [-u] [-x] [--format=display-format][--full-time] [--indicator-style=file-type-style][--sort=sort-key] [--time=file-date-and-time-type] [path-name ...]
Description
The command lists directory contents. The contents are sent to the standard output.
In the output contents, permissions are displayed as described in the following:
-
The first character indicates the type of target:
-: Regular file
b: Block special file
c: Character special file
d: Directory
l: Symbolic link
p: FIFO
s: Socket
-
The subsequent nine characters are treated as three sets of three characters which indicate the owner permissions, group permissions, and other user permissions. In Windows, only the owner permissions are displayed.
Order in permissions
Displayed character#
Permission
1
r
Read by owner
2
w
Write by owner
3
x
Execute by owner
s
Set user ID or set group ID by owner/execute
S
Set user ID or set group ID by owner/no execute
4
r
Read by group
5
w
Write by group
6
x
Execute by group
s
Set user ID or set group ID by group/execute
S
Set user ID or set group ID by group/no execute
7
r
Read by other users
8
w
Write by other users
9
x
Execute by other users
t
Sticky bits by other users/execute
T
Sticky bits by other users/no execute
Character
Meaning
-
The corresponding permission is not granted.
r
In Windows, files or directories exist.
In UNIX, read permissions are granted.
w
In Windows, the read-only attribute is not set.
In UNIX, write permissions are granted.
x
In Windows, one of the following:
-
The extension is .com, .exe, .cmd, or .bat.
-
This is a directory.
In UNIX, execute permissions are granted.
s
Set user ID or set group ID is granted and execute permissions are granted (UNIX only).
S
Set user ID or set group ID is granted, but execute permissions are not granted (UNIX only).
t
Sticky bits are granted and execute permissions are granted (UNIX only).
T
Sticky bits are granted, but execute permissions are not granted (UNIX only).
-
If the -g, -l, -n, or --full-time option is specified, results are output in the long format.
The long format means that not only file and directory names but detailed information about files and directories are output. You can change the output format for each item by combining the long format with the -h, -T, and -u options.
Arguments
- --format=single-column
-
Specifies that the list format is to be one entry per line (in a single column).
- --almost-all
-
Specifies that all entries are to be listed except for those from those from . (dot) and .. (dot dot) files.
- --all
-
Specifies that all files and directories, including those with names starting with . (dot), are to be listed.
- --format=vertical
-
Specifies that entries are to be listed in multiple columns, sorted vertically. This is the default for output to the terminal.
- --time=status
-
Specifies that the date and time of the last change in file information rather than the most recent modification date and time is to be used for sorting (-t option) and for list output (-g, -l, -n, and --full-time options).
- --directory
-
Specifies that only the directory names are to be listed, without displaying the contents of the directories.
- --indicator-style=classify
-
Specifies that a forward slash (/) is to be output after a directory name, an asterisk (*) is to be output after an executable file, an at mark (@) is to be output after a symbolic link, a vertical bar (|) is to be output after a FIFO name, and an equal sign (=) is to be output after a socket.
- --sort=none
-
Specifies that the list is to be output without sorting.
- -g
-
Specifies that the list is to be output in long format, but without listing the file owners.
- --human-readable
-
Specifies that when the long format is used, file sizes are to be divided by a power of 2 and rounded off to two decimal places for display purposes. A size letter (M for 1048576 or K for 1024) is to be added to the file size.
The -h option is ignored for any special files in a directory.
- --inode
-
In UNIX, specifies that each file's inode number is to be output.
In Windows, 0 is always output.
- -k
-
In UNIX, specifies that KB is to be output as the units for listing file sizes with the -s option and as the units for listing the total number of blocks for directories with the -l, -g, -s, and --full-time options.
In Windows, specifies that KB is to be output as the units for listing file sizes with the -s option.
- --dereference
-
In UNIX, specifies that list information about a referenced file rather than the symbolic link itself is to be output.
In Windows, list information about a referenced file is always output.
- --format=verbose
-
Specifies that the list is to be output in long format with the following items displayed. To output date and time in the complete format, specify the --full-time option.
-
UNIX
Access permissions, number of links, owner name, group name, size, most recent modification date and time, name of file or directory. If the target is directories, the total number of directories including . and .. under that directory are displayed.
-
Windows
Access permissions for the owner of the file, owner name, size (except for directories), most recent modification date and time, name of file or directory
-
- --numeric-uid-gid
-
In UNIX, specifies that user IDs and group IDs are to be listed instead of user names and group names.
In Windows, 0 is listed for a user ID, and group IDs are not output.
- --hide-control-chars
-
Specifies that a question mark (?) is to be output for any unprintable character used in a file name. This is the default for output to the terminal.
- --size
-
In UNIX, specifies that the number of blocks in each file, rounded up to full blocks, is to be output. A block is 512 bytes, unless you also specify the -k option or have defined the BLOCKSIZE environment variable.
In Windows, the number of blocks is always listed as 0.
- -T
-
Specifies that date and time information is to be listed in the order month, date, hour, minute, second, and year. This option is specified together with the -g, -l, or -n option.
- --sort=time
-
Specifies that the entries are to be sorted by most recent modification date and time, starting with the most recent.
- --time=use
-
Specifies that the most recent access date and time instead of the most recent modification date and time is to be used when sorting (-t option) or listing in the long format (-g, -l, -n, or --full-time option).
- --format=horizontal
-
Specifies that entries are to be listed in multiple columns, as with -C, but sorted horizontally.
- --format=display-format
-
Specifies the format for displaying file or directory contents.
The permitted values for display formats are listed below. If the --format option is specified more than once, the last option specified takes effect.
across or horizontal
Specifies that entries are to be listed in multiple columns, sorted horizontally. This is the same as the -x option.
- commas
-
Displays file names separated by the comma (,). This is the same as the -m option.
- long or verbose
-
Displays in the long format. This is the same as the -l option.
- single-column
-
Displays one entry (one column) per line. This is the same as the -l option.
- vertical
-
Displays multiple columns, sorted vertically. This is the same as the -C option.
- --full-time
-
Specifies that the same items as when the -l option is specified are to be output. However, information about the date and time is to be output in the complete format, not in the default abbreviated format.
The output format for the date and time information is as follows:
- YYYY-MM-DD hh:mm:ss.nnnnnnnnn +/-hhmm
-
YYYY: Calendar year
MM: Month
DD: Date
hh: Hour
mm: Minute
ss: Second
nnnnnnnnn: Date and time less than one second. 000000000 is always output.
+/-hhmm: Time zone (the time differential from UTC).
- --indicator-style=file-type-style
-
Specifies the style to be used to display information about the file type.
The following values are supported:
- classify
-
Outputs the character indicating the file type immediately after the file name. For a directory name, a forward slash (/) is displayed immediately after the directory name. This is the same as the -F option.
For details about the characters used to indicate file types, see the description of the -F option.
- slash
-
Displays a forward slash (/) immediately after the directory name. This is the same as the -p option.
If --indicator-style=classify is specified together with --indicator-style=slash, the classify specification takes effect.
In Windows, classify is ignored, if specified.
- --sort=sort-key
-
Specifies that when multiple files are displayed, they are to be sorted by the file information indicated by the specified sort key. If the --sort option is specified more than once, the last specification takes effect.
For the sort key, the following values are supported:
- size
-
Sorts files by file size. This is the same as the -S option.
- time
-
Sorts files by most recent modification date and time. This is the same as the -t option. You can also specify the --time option to sort files by the date and time each was last accessed or changed.
- none
-
Outputs files without sorting them. This is the same as the -f option.
- --time=file-date-and-time-type
-
Specifies a file date and time type that is to be applied to date and time information used for sorting (-t) and listing (the -g, -l, -n, and --full-time options). If the --time option is specified more than once, the last specification takes effect. If more than one option is specified, the last option takes effect. In Windows, --time is ignored, if specified.
For the file date and time type, the following values are supported:
- atime, access, or use
-
Uses the last date and time files were accessed. This is the same as the -u option.
- ctime or status
-
Uses the last date and time file information was changed. This is the same as the -c option.
- path-name
-
Specifies the name of a file or directory that is to be listed. More than one can be specified.
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
1 or greater |
Error termination |
Notes
-
If more than one of the -1, -C, -l, -m, -x and --full-time options is specified, the one specified last takes effect.
However, if the -l option is specified together with the --full-time option, the --full-time option takes effect.
-
All entries other than . (dot) or .. (dot dot), including entries that start with . (dot), are eligible to be listed, regardless of whether the -A option is specified.
-
The default block size is 512 bytes.
-
If the date and time associated with a file is at least 182 days (about six months) distant from the time the command is executed, the year is listed instead of the date and time.
However, this does not apply when the --full-time option is specified.
-
In UNIX, if the user name or group name cannot be acquired, the user ID or group ID, respectively, is displayed.
-
In Windows, the -F, -c, and -u options are ignored.
-
In Windows, an ellipsis (...) is displayed when the user name cannot be obtained.
-
In Windows, the total size of the files in the directory is displayed in bytes.
-
In Windows, hidden file attributes can be displayed.
-
This command is affected by the following environment variables:
-
COLUMNS environment variable
Sets the output width per line when listing in multiple columns with the -C option. You cannot define this within a job definition script in JP1/Advanced Shell.
-
BLOCKSIZE environment variable
In UNIX, sets the size of a block for purposes of displaying the number of blocks with the -s option. The permitted value range is from 512 to 1 GB (1,024 1,024 1,024). If the specified value is outside this range, the command handles it as described below, outputs a warning message to the standard error output, and then performs the subsequent processing:
If a value smaller than 512 is specified in the BLOCKSIZE environment variable
The block size is set to 512 bytes.
If a value greater than 1 GB (1,024 1,024 1,024) is specified in the BLOCKSIZE environment variable
The block size is set to 1 gigabyte (1,024 1,024 1,024).
If you use the BLOCKSIZE environment variable to change the block size, specify a multiple of 512. If the specified value is not a multiple of 512, the remainder will be discarded. For example, if a size of 1,500 bytes is defined, the block size will be treated as being 1,024 bytes. You can specify following the numeric value a size character indicating a multiple, such as G (1,024 1,024 1,024), M (1,024 1,024), or K (1,024). If any value other than a numeric value and size character is specified, the command will assume 512 bytes as the block size, output a warning message to the standard error output, and then resume the subsequent processing.
-
TZ environment variable
In UNIX, sets the time zone used to display the date and time.
In Windows, the time zone set in the Date and Time control panel is used to display the date and time. The value of the TZ environment variable is ignored.
Note that the --full-time option uses the value of the TZ environment variable and the time zone set in the Date and Time control panel. For this reason, you must ensure sure that the value of the TZ environment variable and the time zone set in the Date and Time control panel are the same. If they differ, the correct time zone will not be displayed by the --full-time option.
-
-
In Windows, when you specify a drive letter as the directory, depending on how it is specified, it might reference the current directory where the command is being executed.
Examples based on the following folder organization are explained below:
Current drive Other drive D:\ E:\ | | + X + R + Y + S + Z + T | | + file1 + fileA + file2 + fileB + file3 + fileC
When the current drive (D:) is specified, the entries under the directory where the command is executed are listed (D:\Z):
D:\Z>ls -l D: total 462 -rw------- ouser001 154 Jun 02 15:23 file1 -rw------- ouser001 154 Jun 02 15:23 file2 -rw------- ouser001 154 Jun 02 15:23 file3 D:\Z>
Specify the current drive (D:\) to list the entries directly under the specified drive letter (D:\):
D:\Z>ls -l D:\ total 0 drwx------ ouser001 Jun 02 15:22 X drwx------ ouser001 Jun 02 15:23 Y drwx------ ouser001 Jun 02 15:25 Z D:\Z>
Specify another drive (E:) to list the entries directly under the specified drive letter (E:\):
D:\Z>ls -l E: total 0 drwx------ ouser001 Jun 02 15:24 R drwx------ ouser001 Jun 02 15:24 S drwx------ ouser001 Jun 02 15:25 T D:\Z>
Specify another drive (E:\) to list the entries directly under the specified drive letter (E:\):
D:\Z>ls -l E:\ total 0 drwx------ ouser001 Jun 02 15:24 R drwx------ ouser001 Jun 02 15:24 S drwx------ ouser001 Jun 02 15:25 T D:\Z>
Usage examples
-
Specify no option to display files in the current directory.
C:\TEMP>%ADSH_OSCMD_DIR%\ls cmp.exe grep.exe mv.exe sleep.exe cp.exe hostname.exe spool Adshuxpl.dll date.exe ls.exe rm.exe tmp cat.exe mkdir.exe rmdir.exe uname.exe
-
Specify the -1 option to list entries in a single column.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -1 Adshuxpl.dll cat.exe cmp.exe cp.exe date.exe grep.exe hostname.exe ls.exe mkdir.exe mv.exe rm.exe rmdir.exe sleep.exe spool tmp uname.exe
-
Specify the -A option to list all entries except . (dot) and .. (dot dot). In Windows, entries that begin with . (dot) are always listed, regardless of whether the -A option is specified.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -A abcde.txt date.exe hostname.exe rm.exe uname.exe abcdex.txt ls.exe rmdir.exe Adshuxpl.dll cat.exe file1.txt mkdir.exe sleep.exe abc.txt cmp.exe mv.exe spool abcd.txt cp.exe grep.exe tmp
-
Specify the -a option to include directories that begin with . (dot).
C:\TEMP>%ADSH_OSCMD_DIR%\ls -a . cat.exe mv.exe spool .. cmp.exe grep.exe tmp cp.exe hostname.exe rm.exe uname.exe date.exe ls.exe rmdir.exe Adshuxpl.dll mkdir.exe sleep.exe
-
Specify the -C option to list entries in multiple columns sorted vertically.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -C cmp.exe mkdir.exe rmdir.exe uname.exe cp.exe grep.exe mv.exe sleep.exe Adshuxpl.dll date.exe hostname.exe spool cat.exe ls.exe rm.exe tmp
-
Specify the -f option to list without sorting.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -f Adshuxpl.dll cmp.exe mkdir.exe rmdir.exe uname.exe cp.exe grep.exe mv.exe sleep.exe date.exe hostname.exe spool cat.exe ls.exe rm.exe tmp
-
Specify the -g option to list entries in long format, but omitting the owner. In the case of Windows, the group name is omitted.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -g total 1069363 -rw------- 439808 May 09 11:31 Adshuxpl.dll -rwx------ 10752 May 09 11:34 cat.exe -rwx------ 10240 May 09 11:34 cmp.exe -rwx------ 18432 May 09 11:34 cp.exe -rwx------ 10240 May 09 11:34 date.exe -rwx------ 43008 May 09 11:33 grep.exe -rwx------ 7680 May 09 11:33 hostname.exe -rwx------ 22528 May 09 16:27 ls.exe -rwx------ 8192 May 09 11:33 mkdir.exe -rwx------ 12288 May 09 11:33 mv.exe -rwx------ 16384 May 09 11:33 rm.exe -rwx------ 8192 May 09 11:32 rmdir.exe -rwx------ 8192 May 09 11:32 sleep.exe drwx------ May 10 08:50 spool drwx------ May 10 08:50 tmp -rwx------ 9216 May 09 11:32 uname.exe
-
Specify the -h option together with the long format option to append a size letter to the file size.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -lh total 1069363 -rw------- 10379780 430K May 09 11:31 Adshuxpl.dll -rwx------ 10379780 10.5K May 09 11:34 cat.exe -rwx------ 10379780 10.0K May 09 11:34 cmp.exe -rwx------ 10379780 18.0K May 09 11:34 cp.exe -rwx------ 10379780 10.0K May 09 11:34 date.exe -rwx------ 10379780 42.0K May 09 11:33 grep.exe -rwx------ 10379780 7.5K May 09 11:33 hostname.exe -rwx------ 10379780 22.0K May 09 16:27 ls.exe -rwx------ 10379780 8.0K May 09 11:33 mkdir.exe -rwx------ 10379780 12.0K May 09 11:33 mv.exe -rwx------ 10379780 16.0K May 09 11:33 rm.exe -rwx------ 10379780 8.0K May 09 11:32 rmdir.exe -rwx------ 10379780 8.0K May 09 11:32 sleep.exe drwx------ 10379780 May 10 08:50 spool drwx------ 10379780 May 10 08:50 tmp -rwx------ 10379780 9.0K May 09 11:32 uname.exe
-
Specify the -i option to display the inode number for each file. In the case of Windows, 0 is displayed for the inode number.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -i 0 cp.exe 0 hostname.exe 0 rm.exe 0 uname.exe 0 date.exe 0 ls.exe 0 rmdir.exe 0 Adshuxpl.dll 0 mkdir.exe 0 sleep.exe 0 cat.exe 0 mv.exe 0 spool 0 cmp.exe 0 grep.exe 0 tmp C:\TEMP>%ADSH_OSCMD_DIR%\ls -il total 1069363 0 -rw------- 10379780 439808 May 09 11:31 Adshuxpl.dll 0 -rwx------ 10379780 10752 May 09 11:34 cat.exe 0 -rwx------ 10379780 10240 May 09 11:34 cmp.exe 0 -rwx------ 10379780 18432 May 09 11:34 cp.exe 0 -rwx------ 10379780 10240 May 09 11:34 date.exe 0 -rwx------ 10379780 43008 May 09 11:33 grep.exe 0 -rwx------ 10379780 7680 May 09 11:33 hostname.exe 0 -rwx------ 10379780 22528 May 09 16:27 ls.exe 0 -rwx------ 10379780 8192 May 09 11:33 mkdir.exe 0 -rwx------ 10379780 12288 May 09 11:33 mv.exe 0 -rwx------ 10379780 16384 May 09 11:33 rm.exe 0 -rwx------ 10379780 8192 May 09 11:32 rmdir.exe 0 -rwx------ 10379780 8192 May 09 11:32 sleep.exe 0 drwx------ 10379780 May 10 08:50 spool 0 drwx------ 10379780 May 10 08:50 tmp 0 -rwx------ 10379780 9216 May 09 11:32 uname.exe
-
Specify the -l option to list entries in long format. In Windows, only the access permissions of the owner are displayed, and the group name, link count, and directory size are not displayed.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -l total 1069359 -rw------- 10379780 439808 May 09 11:31 Adshuxpl.dll -rwx------ 10379780 10752 May 09 11:34 cat.exe -rwx------ 10379780 10240 May 09 11:34 cmp.exe -rwx------ 10379780 18432 May 09 11:34 cp.exe -rwx------ 10379780 10240 May 09 11:34 date.exe -rwx------ 10379780 43008 May 09 11:33 grep.exe -rwx------ 10379780 7680 May 09 11:33 hostname.exe -rwx------ 10379780 22528 May 09 16:27 ls.exe -rwx------ 10379780 8192 May 09 11:33 mkdir.exe -rwx------ 10379780 12288 May 09 11:33 mv.exe -rwx------ 10379780 16384 May 09 11:33 rm.exe -rwx------ 10379780 8192 May 09 11:32 rmdir.exe -rwx------ 10379780 8192 May 09 11:32 sleep.exe drwx------ 10379780 May 10 08:50 spool drwx------ 10379780 May 10 08:50 tmp -rwx------ 10379780 9216 May 09 11:32 uname.exe
-
Specify the -l option together with the -c option to display the date and time of the most recent change in file information instead of the most recent modification date and time. Windows ignores the -c option and displays the most recent modification date and time.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -lc total 1069363 -rw------- 10379780 439808 May 09 11:31 Adshuxpl.dll -rwx------ 10379780 10752 May 09 11:34 cat.exe -rwx------ 10379780 10240 May 09 11:34 cmp.exe -rwx------ 10379780 18432 May 09 11:34 cp.exe -rwx------ 10379780 10240 May 09 11:34 date.exe -rwx------ 10379780 43008 May 09 11:33 grep.exe -rwx------ 10379780 7680 May 09 11:33 hostname.exe -rwx------ 10379780 22528 May 09 16:27 ls.exe -rwx------ 10379780 8192 May 09 11:33 mkdir.exe -rwx------ 10379780 12288 May 09 11:33 mv.exe -rwx------ 10379780 16384 May 09 11:33 rm.exe -rwx------ 10379780 8192 May 09 11:32 rmdir.exe -rwx------ 10379780 8192 May 09 11:32 sleep.exe drwx------ 10379780 May 10 08:50 spool drwx------ 10379780 May 10 08:50 tmp -rwx------ 10379780 9216 May 09 11:32 uname.exe
-
Specify the -l option together with the -u option to display the most recent access date and time instead of the most recent modification date and time. Windows ignores the -u option and displays the most recent modification date and time.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -lu total 1069363 -rw------- 10379780 439808 May 09 11:31 Adshuxpl.dll -rwx------ 10379780 10752 May 09 11:34 cat.exe -rwx------ 10379780 10240 May 09 11:34 cmp.exe -rwx------ 10379780 18432 May 09 11:34 cp.exe -rwx------ 10379780 10240 May 09 11:34 date.exe -rwx------ 10379780 43008 May 09 11:33 grep.exe -rwx------ 10379780 7680 May 09 11:33 hostname.exe -rwx------ 10379780 22528 May 09 16:27 ls.exe -rwx------ 10379780 8192 May 09 11:33 mkdir.exe -rwx------ 10379780 12288 May 09 11:33 mv.exe -rwx------ 10379780 16384 May 09 11:33 rm.exe -rwx------ 10379780 8192 May 09 11:32 rmdir.exe -rwx------ 10379780 8192 May 09 11:32 sleep.exe drwx------ 10379780 May 10 08:50 spool drwx------ 10379780 May 10 08:50 tmp -rwx------ 10379780 9216 May 09 11:32 uname.exe
-
Specify the -m option to list entries in stream output format delimited by the comma.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -m Adshuxpl.dll, cat.exe, cmp.exe, cp.exe, date.exe, grep.exe, hostname.exe, ls.exe, mkdir.exe, mv.exe, rm.exe, rmdir.exe, sleep.exe, spool, tmp, uname.exe
-
Specify the -n option to display user ID and group ID instead of user name and group name. In Windows, 0 is displayed for the user ID and group IDs are not output.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -n total 1069363 -rw------- 0 439808 May 09 11:31 Adshuxpl.dll -rwx------ 0 10752 May 09 11:34 cat.exe -rwx------ 0 10240 May 09 11:34 cmp.exe -rwx------ 0 18432 May 09 11:34 cp.exe -rwx------ 0 10240 May 09 11:34 date.exe -rwx------ 0 43008 May 09 11:33 grep.exe -rwx------ 0 7680 May 09 11:33 hostname.exe -rwx------ 0 22528 May 09 16:27 ls.exe -rwx------ 0 8192 May 09 11:33 mkdir.exe -rwx------ 0 12288 May 09 11:33 mv.exe -rwx------ 0 16384 May 09 11:33 rm.exe -rwx------ 0 8192 May 09 11:32 rmdir.exe -rwx------ 0 8192 May 09 11:32 sleep.exe drwx------ 0 May 10 08:50 spool drwx------ 0 May 10 08:50 tmp -rwx------ 0 9216 May 09 11:32 uname.exe
-
Specify the -p option to display a forward slash (/) after a directory name.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -p cp.exe hostname.exe rm.exe uname.exe date.exe ls.exe rmdir.exe mkdir.exe sleep.exe cat.exe mv.exe spool/ cmp.exe grep.exe tmp/ C:\TEMP>%ADSH_OSCMD_DIR%\ls -alp total 1069363 drwx------ 10379780 May 10 09:45 ./ drwx------ 10379780 May 10 10:02 ../ -rw------- 10379780 439808 May 09 11:31 Adshuxpl.dll -rwx------ 10379780 10752 May 09 11:34 cat.exe -rwx------ 10379780 10240 May 09 11:34 cmp.exe -rwx------ 10379780 18432 May 09 11:34 cp.exe -rwx------ 10379780 10240 May 09 11:34 date.exe -rwx------ 10379780 43008 May 09 11:33 grep.exe -rwx------ 10379780 7680 May 09 11:33 hostname.exe -rwx------ 10379780 22528 May 09 16:27 ls.exe -rwx------ 10379780 8192 May 09 11:33 mkdir.exe -rwx------ 10379780 12288 May 09 11:33 mv.exe -rwx------ 10379780 16384 May 09 11:33 rm.exe -rwx------ 10379780 8192 May 09 11:32 rmdir.exe -rwx------ 10379780 8192 May 09 11:32 sleep.exe drwx------ 10379780 May 10 08:50 spool/ drwx------ 10379780 May 10 08:50 tmp/ -rwx------ 10379780 9216 May 09 11:32 uname.exe
-
Specify the -q option to show unprintable characters as a question mark (?).
C:\TEMP>%ADSH_OSCMD_DIR%\ls -q ..\dir1 .sub1 file2.txt sub4 wc2.c wc4.c .sub2 sub3 wc1.c wc3.c ????.txt
-
Specify the -R option to list subdirectories recursively.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -R ..\dir1 .sub1 file2.txt sub4 wc2.c wc4.c .sub2 sub3 wc1.c wc3.c ????.txt ..\dir1\.sub1: ..\dir1\.sub2: ..\dir1\sub3: ..\dir1\sub4:
-
Specify the -r option to list entries sorted in reverse order.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -r spool hostname.exe date.exe Adshuxpl.dll sleep.exe mv.exe grep.exe cp.exe uname.exe rmdir.exe mkdir.exe cmp.exe tmp rm.exe ls.exe cat.exe C:\TEMP>%ADSH_OSCMD_DIR%\ls -rl total 1069363 -rwx------ 10379780 9216 May 09 11:32 uname.exe drwx------ 10379780 May 10 08:50 tmp drwx------ 10379780 May 10 08:50 spool -rwx------ 10379780 8192 May 09 11:32 sleep.exe -rwx------ 10379780 8192 May 09 11:32 rmdir.exe -rwx------ 10379780 16384 May 09 11:33 rm.exe -rwx------ 10379780 12288 May 09 11:33 mv.exe -rwx------ 10379780 8192 May 09 11:33 mkdir.exe -rwx------ 10379780 22528 May 09 16:27 ls.exe -rwx------ 10379780 7680 May 09 11:33 hostname.exe -rwx------ 10379780 43008 May 09 11:33 grep.exe -rwx------ 10379780 10240 May 09 11:34 date.exe -rwx------ 10379780 18432 May 09 11:34 cp.exe -rwx------ 10379780 10240 May 09 11:34 cmp.exe -rwx------ 10379780 10752 May 09 11:34 cat.exe -rw------- 10379780 439808 May 09 11:31 Adshuxpl.dll
-
Specify the -S option to sort by size, from largest to smallest.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -S Adshuxpl.dll rm.exe cmp.exe mkdir.exe ls.exe mv.exe date.exe rmdir.exe spool cat.exe sleep.exe tmp grep.exe cp.exe uname.exe hostname.exe C:\TEMP>%ADSH_OSCMD_DIR%\ls -lS total 1069363 -rw------- 10379780 439808 May 09 11:31 Adshuxpl.dll -rwx------ 10379780 43008 May 09 11:33 grep.exe -rwx------ 10379780 22528 May 09 16:27 ls.exe -rwx------ 10379780 18432 May 09 11:34 cp.exe -rwx------ 10379780 16384 May 09 11:33 rm.exe -rwx------ 10379780 12288 May 09 11:33 mv.exe -rwx------ 10379780 10752 May 09 11:34 cat.exe -rwx------ 10379780 10240 May 09 11:34 cmp.exe -rwx------ 10379780 10240 May 09 11:34 date.exe -rwx------ 10379780 9216 May 09 11:32 uname.exe -rwx------ 10379780 8192 May 09 11:33 mkdir.exe -rwx------ 10379780 8192 May 09 11:32 rmdir.exe -rwx------ 10379780 8192 May 09 11:32 sleep.exe -rwx------ 10379780 7680 May 09 11:33 hostname.exe drwx------ 10379780 May 10 08:50 spool drwx------ 10379780 May 10 08:50 tmp
-
Specify the -s option to display the number of blocks for each file. In Windows, 0 is displayed.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -sl total 1070036 0 -rw------- 10379780 439808 May 09 11:31 Adshuxpl.dll 0 -rw------- 10379780 90 May 10 10:46 abc.txt 0 -rw------- 10379780 152 May 10 15:25 abcd.txt 0 -rw------- 10379780 179 May 10 11:01 abcde.txt 0 -rw------- 10379780 146 May 10 15:22 abcdex.txt 0 -rwx------ 10379780 10752 May 09 11:34 cat.exe 0 -rwx------ 10379780 10240 May 09 11:34 cmp.exe 0 -rwx------ 10379780 18432 May 09 11:34 cp.exe 0 -rwx------ 10379780 10240 May 09 11:34 date.exe 0 -rw------- 10379780 106 May 10 13:58 file1.txt 0 -rwx------ 10379780 43008 May 09 11:33 grep.exe 0 -rwx------ 10379780 7680 May 09 11:33 hostname.exe 0 -rwx------ 10379780 22528 May 09 16:27 ls.exe 0 -rwx------ 10379780 8192 May 09 11:33 mkdir.exe 0 -rwx------ 10379780 12288 May 09 11:33 mv.exe 0 -rwx------ 10379780 16384 May 09 11:33 rm.exe 0 -rwx------ 10379780 8192 May 09 11:32 rmdir.exe 0 -rwx------ 10379780 8192 May 09 11:32 sleep.exe 0 drwx------ 10379780 May 10 08:50 spool 0 drwx------ 10379780 May 10 08:50 tmp 0 -rwx------ 10379780 9216 May 09 11:32 uname.exe
-
Specify the -T option to display time information as the month, date, hour, minute, second, and year.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -lT total 1069363 -rw------- 10379780 439808 May 09 11:31:40 2011 Adshuxpl.dll -rwx------ 10379780 10752 May 09 11:34:28 2011 cat.exe -rwx------ 10379780 10240 May 09 11:34:20 2011 cmp.exe -rwx------ 10379780 18432 May 09 11:34:35 2011 cp.exe -rwx------ 10379780 10240 May 09 11:34:13 2011 date.exe -rwx------ 10379780 43008 May 09 11:33:44 2011 grep.exe -rwx------ 10379780 7680 May 09 11:33:34 2011 hostname.exe -rwx------ 10379780 22528 May 09 16:27:40 2011 ls.exe -rwx------ 10379780 8192 May 09 11:33:15 2011 mkdir.exe -rwx------ 10379780 12288 May 09 11:33:53 2011 mv.exe -rwx------ 10379780 16384 May 09 11:33:01 2011 rm.exe -rwx------ 10379780 8192 May 09 11:32:54 2011 rmdir.exe -rwx------ 10379780 8192 May 09 11:32:49 2011 sleep.exe drwx------ 10379780 May 10 08:50:19 2011 spool drwx------ 10379780 May 10 08:50:19 2011 tmp -rwx------ 10379780 9216 May 09 11:32:44 2011 uname.exe
-
Specify the -t option to sort files in the order of most recent modification date and time.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -t date.exe hostname.exe rmdir.exe spool cp.exe mkdir.exe sleep.exe tmp cat.exe mv.exe uname.exe Adshuxpl.dll ls.exe cmp.exe grep.exe rm.exe C:\TEMP>%ADSH_OSCMD_DIR%\ls -lt total 1069363 drwx------ 10379780 May 10 08:50 spool drwx------ 10379780 May 10 08:50 tmp -rwx------ 10379780 22528 May 09 16:27 ls.exe -rwx------ 10379780 18432 May 09 11:34 cp.exe -rwx------ 10379780 10752 May 09 11:34 cat.exe -rwx------ 10379780 10240 May 09 11:34 cmp.exe -rwx------ 10379780 10240 May 09 11:34 date.exe -rwx------ 10379780 12288 May 09 11:33 mv.exe -rwx------ 10379780 43008 May 09 11:33 grep.exe -rwx------ 10379780 7680 May 09 11:33 hostname.exe -rwx------ 10379780 8192 May 09 11:33 mkdir.exe -rwx------ 10379780 16384 May 09 11:33 rm.exe -rwx------ 10379780 8192 May 09 11:32 rmdir.exe -rwx------ 10379780 8192 May 09 11:32 sleep.exe -rwx------ 10379780 9216 May 09 11:32 uname.exe -rw------- 10379780 439808 May 09 11:31 Adshuxpl.dll
-
Specify the -x option to list entries in multiple columns sorted horizontally.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -x Adshuxpl.dll cat.exe cmp.exe cp.exe date.exe grep.exe hostname.exe ls.exe mkdir.exe mv.exe rm.exe rmdir.exe sleep.exe spool tmp uname.exe
-
Specify the --full-time option to display the date and time information in the complete long format.
C:\Program Files\HITACHI\JP1AS\JP1ASE\cmd>ls --full-time total 2638901 -rwx------ SYSTEM 327168 2014-01-10 19:47:42.000000000 +0900 awk.exe -rwx------ SYSTEM 10240 2014-01-10 19:45:32.000000000 +0900 basename.exe -rwx------ SYSTEM 12800 2014-01-10 19:48:44.000000000 +0900 cat.exe -rwx------ SYSTEM 11264 2014-01-10 19:48:44.000000000 +0900 cmp.exe -rwx------ SYSTEM 19968 2014-01-10 19:48:40.000000000 +0900 cp.exe -rwx------ SYSTEM 14848 2014-01-10 19:48:04.000000000 +0900 cut.exe -rwx------ SYSTEM 10240 2014-01-10 19:48:36.000000000 +0900 date.exe -rwx------ SYSTEM 237056 2014-01-10 19:48:14.000000000 +0900 diff.exe -rwx------ SYSTEM 224256 2014-01-10 19:45:28.000000000 +0900 egrep.exe
-
Display option error massages:
This message might vary depending on the platform used to execute the command. The following is an example for Windows:
C:\>ls -z ls: illegal option -- z usage: ls [-1AaCcdFfghikLlmnpqRrSsTtux] [--format=word] [--full-time] [--indicator-style=word] [--sort=word] [--time=word] [file ...]