utility

ls — external utility

Lists directory entries or specified names; -1 requests one entry per line and -a includes hidden entries. Output varies by locale, terminal and quoting rules; filenames may contain newlines. Use glob arrays or find with NUL separators for reliable filename processing, not parsing ls output. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): a.txt; b.txt.

Formal Syntax & Structure

bash syntaxbash
ls [OPTION]... [FILE]...

Parameters & Attributes

NameTypeDescription
FILEpathFiles or directories to list.

Return Value

exit status

Zero on successful operation; nonzero on errors.

Working Example

Example Snippetbash
mkdir sampletouch sample/a.txt sample/b.txt sample/.hiddenLC_ALL=C /usr/bin/ls -1 -- sample
Bash Reference