LS [/1alRrSt] [filespec]…
Lists files and directories like the UNIX ls command. Each filespec that’s a directory (eg, LS \EXT\CMD, LS .., or LS A:) lists the files in that directory, and without one, the current directory is listed. Any other filespec lists the files that match it (and with wildcards, the directories that match it, too), with the filespec’s drive and path in front of each name, as a UNIX shell would expand them (eg, LS \EXT\CMD\T*.COM lists \EXT\CMD\TEE.COM \EXT\CMD\TR.COM); those files are listed first, all together, and then each directory, after a line with its name and a colon if more than one filespec was given. A filespec that matches nothing is reported (eg, Unable to find X.BAS).
Names are sorted, and listed in columns down the screen, each 16 characters wide, as DIR /W lists them (or a multiple of 16, if the longest name, with its drive and path, is more than 14 characters), with as many columns as fit the console’s width (5 on an 80-column screen, or 2 on a 40-column screen); to use every column, the columns on the right can have one name fewer than those on the left. Each directory’s name ends with the path character (eg, EXT\), as UNIX’s ls -p shows directories; programs aren’t marked. When the output isn’t the console (eg, LS > FILES.TXT), names are listed one per line, as UNIX does. Hidden files, and the . and .. entries of a subdirectory, are listed only with /a.
Options start with the switch character (/, unless SWITCHAR changes it, eg, to -), are case-sensitive, and can be combined (eg, LS /ltr is the same as LS /l /t /r):
/1 lists one name per line/a lists all files, including hidden files and the . and .. entries/l lists each file’s mode, size, date, and name, after a total line with the directory’s size in K (the sum of each file’s size rounded up to a whole K); the mode is d for a directory (or -), followed by rwx for a directory or program (a COM, EXE, BAT, or BAS file), or rw- for any other file, without the w for a read-only file. Sizes are right-justified in 7 columns. The date shows the time if it’s within the last 6 months, or else the year. Since files have no owners or links, there are no owner, group, or link count columns, and only one set of permissions./R lists the subdirectories of each directory listed, too, after a line with each one’s path (eg, .\TESTS:)/r reverses the order/S sorts by size, largest first/t sorts by date and time, newest first (and /tr, oldest first)Files with the same size or time are sorted by name. If there are more names than LS can sort, or more directories waiting to be listed than it can remember, LS displays Too many matching files, and ERRORLEVEL is set to 1. A drive that doesn’t exist displays Invalid drive, and any other option is a usage error.
LS \EXT\CMD
DEBUG.COM HELP.TXT SLEEP.COM TR.COM VI.COM
FIND.COM MORE.COM SORT.COM UNIQ.COM WC.COM
HELP.COM SED.COM TEE.COM V86.COM
LS \
AUTOEXEC.BAT CONFIG.SYS EXT\ TESTS\ TOOLS\
COMMAND.COM
LS /lt \EXT\CMD\T*.*
-rwx 578 Nov 21 16:57 \EXT\CMD\TEE.COM
-rwx 570 Nov 21 16:57 \EXT\CMD\TR.COM
Source: LS.BAS
Copyright (c) 2020-2026 Jeff Parsons Released under MIT License