Skip to Main Content Skip to Search
Product Documentation

ls - List folder contents

Syntax

ls
ls name
list = ls(name)

Description

ls lists the contents of the current folder.

ls name lists the files and folders in the current folder that match the specified name. You can use wildcards.

list = ls(name) returns the files and folders in the current folder that match the specified name to list.

Tips

Input Arguments

name

A string value specifying a file or folder name.

Output Arguments

list

  • On UNIX platforms, list is a character row vector of names separated by tab and space characters.

  • On Microsoft Windows platforms, list is an m-by-n character array of names—m is the number of names and n is the number of characters in the longest name. MATLAB pads names shorter than n characters with space characters.

Examples

List all the files and folders in the current folder:

ls
 

List all the files and folders in the current folder that begin with the letter h:

ls h*
 

Return the list of all the files and folders in the current folder to mylist:

mylist = ls;

Alternatives

See Also

dir | pwd

How To

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS