8.4.21 ls command (lists the contents of files or directories)
Syntax
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
- #
The following table explains the characters that are displayed:
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
-1
- --format=single-column
Specifies that the list format is to be one entry per line (in a single column).
-A
- --almost-all
Specifies that all entries are to be listed except for those from those from . (dot) and .. (dot dot) files.
-a
- --all
Specifies that all files and directories, including those with names starting with . (dot), are to be listed.
-C
- --format=vertical
Specifies that entries are to be listed in multiple columns, sorted vertically. This is the default for output to the terminal.
-c
--time=ctime
- --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).
In Windows, the specification is ignored.
-d
- --directory
Specifies that only the directory names are to be listed, without displaying the contents of the directories.
In Windows, the directory delimiter at the end is ignored even if you specify this option and specify the symbolic link to the directory having the directory delimiter at the end of its path name. To output contents of the directory of the destination of the symbolic link, specify this option with the -L option.
-F
--classify
- --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. In Windows, the specification is ignored.
-f
- --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.
In Windows, the directory delimiter at the end is ignored even if you specify this option and specify the symbolic link to the directory having the directory delimiter at the end of its path name. To output contents of the directory of the destination of the symbolic link, specify this option with the -L option.
-h
- --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.
-i
- --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.
-L
- --dereference
-
This command outputs information of the file that is being referenced instead of symbolic link.
-l
--format=long
- --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.
If the file is symbolic link, the path name of the link destination appears after "->".
Windows
Access permissions, number of links, owner name, size (this item does not appear for directory), most recent modification date and time, name of file or directory.
If the file is symbolic link, the path name of the link destination appears after "->".
The directory delimiter at the end is ignored even if you specify this option and then specify the symbolic link to the directory having the directory delimiter at the end of its path name. To output contents of the directory of the destination of the symbolic link, specify this option with the -L option.
-m
- --format=commas
Specifies that file names are to be delimited by the comma (,).
-n
- --numeric-uid-gid
-
-
In UNIX
The user ID and group ID are output instead of the user name and group name.
-
In Windows
0 is output for the user ID. The group ID is not output.
The directory delimiter at the end is ignored even if you specify this option and then specify the symbolic link to the directory having the directory delimiter at the end of its path name. To output contents of the directory of the destination of the symbolic link, specify this option with the -L option.
-
-p
- --indicator-style=slash
Specifies that a forward slash (/) is to be output after a directory name.
-q
- --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.
-R
- --recursive
Specifies that subdirectories are to be listed recursively.
-r
- --reverse
Specifies that the output is to be sorted in reverse order.
-S
- --sort=size
Specifies that the entries are to be sorted by size, from largest to smallest.
-s
- --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.
-t
- --sort=time
Specifies that the entries are to be sorted by most recent modification date and time, starting with the most recent.
-u
--time=atime
--time=access
- --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).
In Windows, the specification is ignored.
-x
--format=across
- --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).
In Windows, the directory delimiter at the end is ignored even if you specify this option and specify the symbolic link to the directory having the directory delimiter at the end of its path name. To output contents of the directory of the destination of the symbolic link, specify this option with the -L option.
- --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, 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
The output width for each line when multiple columns are output by specifying the -C option.
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>
Examples
Specify no option to display files in the current directory.
C:\TEMP>%ADSH_OSCMD_DIR%\ls HARDLINK.txt TestLog test_result.txt SYMLINK.txt test_data.txt uap.exe
Specify the -1 option to list entries in a single column.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -1 HARDLINK.txt SYMLINK.txt TestLog test_data.txt test_result.txt uap.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 HARDLINK.txt TestLog test_result.txt SYMLINK.txt test_data.txt uap.exe
Specify the -a option to include directories that begin with . (dot).
C:\TEMP>%ADSH_OSCMD_DIR%\ls -a . SYMLINK.txt test_result.txt .. TestLog uap.exe HARDLINK.txt test_data.txt
Specify the -C option to list entries in multiple columns sorted vertically.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -C HARDLINK.txt TestLog test_result.txt SYMLINK.txt test_data.txt uap.exe
Specify the -f option to list without sorting.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -f HARDLINK.txt TestLog test_result.txt SYMLINK.txt test_data.txt uap.exe
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 337744 -rw------- 2 102000 Jul 06 16:26 HARDLINK.txt lrw------- 1 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt drwx------ 1 Jul 06 16:58 TestLog -rw------- 1 102000 Jul 06 16:20 test_data.txt -rw------- 2 102000 Jul 06 16:26 test_result.txt -rwx------ 1 31744 Jun 12 16:23 uap.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 337744 -rw------- 2 Administrators 99.6K Jul 06 16:26 HARDLINK.txt lrw------- 1 Administrators 0B Jul 06 16:27 SYMLINK.txt -> .\test_data.txt drwx------ 1 Administrators Jul 06 16:58 TestLog -rw------- 1 Administrators 99.6K Jul 06 16:20 test_data.txt -rw------- 2 Administrators 99.6K Jul 06 16:26 test_result.txt -rwx------ 1 Administrators 31.0K Jun 12 16:23 uap.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 HARDLINK.txt 0 TestLog 0 test_result.txt 0 SYMLINK.txt 0 test_data.txt 0 uap.exe C:\TEMP>%ADSH_OSCMD_DIR%\ls -il total 337744 0 -rw------- 2 Administrators 102000 Jul 06 16:26 HARDLINK.txt 0 lrw------- 1 Administrators 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt 0 drwx------ 1 Administrators Jul 06 16:58 TestLog 0 -rw------- 1 Administrators 102000 Jul 06 16:20 test_data.txt 0 -rw------- 2 Administrators 102000 Jul 06 16:26 test_result.txt 0 -rwx------ 1 Administrators 31744 Jun 12 16:23 uap.exe
-
The file is displayed in long format by specifying the -l option. In Windows, only access permissions of the owner appear. Group name and directory size do not appear.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -l total 337744 -rw------- 2 Administrators 102000 Jul 06 16:26 HARDLINK.txt lrw------- 1 Administrators 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt drwx------ 1 Administrators Jul 06 16:58 TestLog -rw------- 1 Administrators 102000 Jul 06 16:20 test_data.txt -rw------- 2 Administrators 102000 Jul 06 16:26 test_result.txt -rwx------ 1 Administrators 31744 Jun 12 16:23 uap.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 337744 -rw------- 2 Administrators 102000 Jul 06 16:26 HARDLINK.txt lrw------- 1 Administrators 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt drwx------ 1 Administrators Jul 06 16:58 TestLog -rw------- 1 Administrators 102000 Jul 06 16:20 test_data.txt -rw------- 2 Administrators 102000 Jul 06 16:26 test_result.txt -rwx------ 1 Administrators 31744 Jun 12 16:23 uap.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 337744 -rw------- 2 Administrators 102000 Jul 06 16:26 HARDLINK.txt lrw------- 1 Administrators 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt drwx------ 1 Administrators Jul 06 16:58 TestLog -rw------- 1 Administrators 102000 Jul 06 16:20 test_data.txt -rw------- 2 Administrators 102000 Jul 06 16:26 test_result.txt -rwx------ 1 Administrators 31744 Jun 12 16:23 uap.exe
Specify the -m option to list entries in stream output format delimited by the comma.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -m HARDLINK.txt, SYMLINK.txt, TestLog, test_data.txt, test_result.txt, uap.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 337744 -rw------- 2 0 102000 Jul 06 16:26 HARDLINK.txt lrw------- 1 0 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt drwx------ 1 0 Jul 06 16:58 TestLog -rw------- 1 0 102000 Jul 06 16:20 test_data.txt -rw------- 2 0 102000 Jul 06 16:26 test_result.txt -rwx------ 1 0 31744 Jun 12 16:23 uap.exe
Specify the -p option to display a forward slash (/) after a directory name.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -p HARDLINK.txt TestLog/ test_result.txt SYMLINK.txt test_data.txt uap.exe C:\TEMP>%ADSH_OSCMD_DIR%\ls -alp total 337744 drwx------ 1 Administrators Jul 06 16:29 ./ drwx------ 1 TrustedInstaller Jan 01 1980 ../ -rw------- 2 Administrators 102000 Jul 06 16:26 HARDLINK.txt lrw------- 1 Administrators 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt drwx------ 1 Administrators Jul 06 16:58 TestLog/ -rw------- 1 Administrators 102000 Jul 06 16:20 test_data.txt -rw------- 2 Administrators 102000 Jul 06 16:26 test_result.txt -rwx------ 1 Administrators 31744 Jun 12 16:23 uap.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 uap.exe test_data.txt SYMLINK.txt test_result.txt TestLog HARDLINK.txt C:\TEMP>%ADSH_OSCMD_DIR%\ls -rl total 337744 -rwx------ 1 Administrators 31744 Jun 12 16:23 uap.exe -rw------- 2 Administrators 102000 Jul 06 16:26 test_result.txt -rw------- 1 Administrators 102000 Jul 06 16:20 test_data.txt drwx------ 1 Administrators Jul 06 16:58 TestLog lrw------- 1 Administrators 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt -rw------- 2 Administrators 102000 Jul 06 16:26 HARDLINK.txt
Specify the -S option to sort by size, from largest to smallest.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -S HARDLINK.txt test_result.txt SYMLINK.txt test_data.txt uap.exe TestLog C:\TEMP>%ADSH_OSCMD_DIR%\ls -lS total 337744 -rw------- 2 Administrators 102000 Jul 06 16:26 HARDLINK.txt -rw------- 1 Administrators 102000 Jul 06 16:20 test_data.txt -rw------- 2 Administrators 102000 Jul 06 16:26 test_result.txt -rwx------ 1 Administrators 31744 Jun 12 16:23 uap.exe lrw------- 1 Administrators 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt drwx------ 1 Administrators Jul 06 16:58 TestLog
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 337744 0 -rw------- 2 Administrators 102000 Jul 06 16:26 HARDLINK.txt 0 lrw------- 1 Administrators 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt 0 drwx------ 1 Administrators Jul 06 16:58 TestLog 0 -rw------- 1 Administrators 102000 Jul 06 16:20 test_data.txt 0 -rw------- 2 Administrators 102000 Jul 06 16:26 test_result.txt 0 -rwx------ 1 Administrators 31744 Jun 12 16:23 uap.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 337744 -rw------- 2 Administrators 102000 Jul 06 16:26:40 2015 HARDLINK.txt lrw------- 1 Administrators 0 Jul 06 16:27:11 2015 SYMLINK.txt -> .\test_data.txt drwx------ 1 Administrators Jul 06 16:58:21 2015 TestLog -rw------- 1 Administrators 102000 Jul 06 16:20:28 2015 test_data.txt -rw------- 2 Administrators 102000 Jul 06 16:26:40 2015 test_result.txt -rwx------ 1 Administrators 31744 Jun 12 16:23:18 2015 uap.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 TestLog HARDLINK.txt test_data.txt SYMLINK.txt test_result.txt uap.exe C:\TEMP>%ADSH_OSCMD_DIR%\ls -lt total 337744 drwx------ 1 Administrators Jul 06 16:58 TestLog lrw------- 1 Administrators 0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt -rw------- 2 Administrators 102000 Jul 06 16:26 HARDLINK.txt -rw------- 2 Administrators 102000 Jul 06 16:26 test_result.txt -rw------- 1 Administrators 102000 Jul 06 16:20 test_data.txt -rwx------ 1 Administrators 31744 Jun 12 16:23 uap.exe
Specify the -x option to list entries in multiple columns sorted horizontally.
C:\TEMP>%ADSH_OSCMD_DIR%\ls -x HARDLINK.txt SYMLINK.txt TestLog test_data.txt test_result.txt uap.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------ 1 SYSTEM 327168 2014-01-10 19:47:42.000000000 +0900 awk.exe -rwx------ 1 SYSTEM 10240 2014-01-10 19:45:32.000000000 +0900 basename.exe -rwx------ 1 SYSTEM 12800 2014-01-10 19:48:44.000000000 +0900 cat.exe -rwx------ 1 SYSTEM 11264 2014-01-10 19:48:44.000000000 +0900 cmp.exe -rwx------ 1 SYSTEM 19968 2014-01-10 19:48:40.000000000 +0900 cp.exe -rwx------ 1 SYSTEM 14848 2014-01-10 19:48:04.000000000 +0900 cut.exe -rwx------ 1 SYSTEM 10240 2014-01-10 19:48:36.000000000 +0900 date.exe -rwx------ 1 SYSTEM 237056 2014-01-10 19:48:14.000000000 +0900 diff.exe -rwx------ 1 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 ...]