Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

ls

List folder contents

Syntax

Description

ls lists the contents of the current folder.

example

ls name lists the files and folders in the current folder that match the specified name.

example

list = ls(___) returns the names of all the files and folders in the current folder that match the specified name. You can specify list with any of the arguments in the previous syntaxes.

Examples

collapse all

List all the files and folders with names that contain my.

ls *my*
my_class.m     my_function.m  my_script.m    my_text.txt

List all the files and folders with a .m extension.

ls *.m
my_class.m       my_function.m    my_script.m      test_function.m

Save a list of the names of all the files and folders in the current folder to the variable MyList.

MyList = ls;

Input Arguments

collapse all

Name of file or folder, specified as a character vector. Use the '*' wildcard to match patterns. For example, ls *.m lists all files and folders with a .m extension, and ls m* lists all files and folders with names that begin with the letter m.

Output Arguments

collapse all

List of files and folders, specified as a character array in one of these formats.

  • UNIX® platformslist is a character vector of names separated by tab and space characters.

  • Microsoft® Windows® platformslist 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.

Alternatives

Use the dir command to return file attributes for each file and folder in the output argument.

You can also view files and folders in the Current Folder browser by issuing the filebrowser command.

More About

collapse all

Tips

  • To further modify the results of the ls command on UNIX platforms, you can add any flags that the operating system supports. For example, ls -c displays files by timestamp and ls -d displays only directories. For more information, see the UNIX ls documentation.

See Also

|

Introduced before R2006a

Was this topic helpful?