next up previous contents
Next: PWD Print Working Directory Up: Operating System Functions Previous: CD Change Working Directory   Contents

Subsections

LS/DIR List Files Function

Usage

Lists the files in a directory or directories. The general syntax for its use is

  ls('dirname1','dirname2',...,'dirnameN')

but this can also be expressed as

  ls 'dirname1' 'dirname2' ... 'dirnameN'

or

  ls dirname1 dirname2 ... dirnameN

For compatibility with some environments, the function dir can also be used instead of ls. Generally speaking, dirname is any string that would be accepted by the underlying OS as a valid directory name. For example, on most systems, '.' refers to the current directory, and '..' refers to the parent directory. Also, depending on the OS, it may be necessary to ``escape'' the directory seperators. In particular, if directories are seperated with the backwards-slash character '\\', then the path specification must use double-slashes '\\\\'. Two points worth mentioning about the ls function:

Example

First, we use the simplest form of the ls command, in which the directory name argument is given unquoted.

--> ls m*.m
mkhsetpath.m    mprintimage.m   mprintplot.m

Next, we use the ``traditional'' form of the function call, using both the parenthesis and the quoted string.

--> ls('m*.m')
mkhsetpath.m    mprintimage.m   mprintplot.m

In the third version, we use only the quoted string argument without parenthesis.

--> ls 'm*.m'
mkhsetpath.m    mprintimage.m   mprintplot.m


next up previous contents
Next: PWD Print Working Directory Up: Operating System Functions Previous: CD Change Working Directory   Contents
Samit K. Basu 2005-03-16