ls
ls is a command to list files in Unix and Unix-like operating systems. ls is specified by POSIX and the Single UNIX Specification.[1]
- GNU Coreutils [EN] @ Fedora Package
- GNU Coreutils [EN] @ Homebrew Formula
Documentation
- ls [EN] @ GNU Coreutils Manual
Syntax
ls [PARAMETER ...] [FILE/DIRECTORY ...]
Parameters
- General
- The following parameters can be used with all version of ls:
- NOTE:BSD version only supports the short form (e.g. -a) of these parameters!
- -1
- List one file per line.
- -a, --all
- Do not ignore entries starting with .
- -A, --almost-all
- Like -a but do not list implied . and ..
- --color[=WHEN]
- Colorize the output. WHEN defaults to always or can be never or auto.
- -F, --classify
- Append indicator (one of */=>@|) to entries:
- * for executables
- / for directories
- = for sockets
- > for doors
- @ for links
- | for fifos
- -h, --human-readable
- Print with -l sizes in human readable format (e.g. 1K, 234M, 2G).
- -i, --inode
- Print the index number of each file.
- -l
- Use a long listing format.
Examples
- List all subdirectories and files of a directory
ls -laFh
- List only subdirectories of a directory
ls -la | grep '^d'
- Define aliases for directory listing
if type -P 'eza' >'/dev/null' 2>&1; then # eza
alias ls="eza --classify --time-style='long-iso'"
alias ll='ls --git --group --header --long'
alias l='ll --all --all'
else
if ls --context >'/dev/null' 2>&1; then # GNU ls version
alias ls="ls --classify --color --time-style='long-iso'"
if type -P 'dircolors' >'/dev/null' 2>&1; then
eval "$(dircolors -b)"
fi
else # other ls versions
alias ls="ls -D '%F %T' -F -G"
fi
alias ll='ls -h -l'
alias l='ll -a'
fi
alias lr='l -R'
alias lt="l -r -s 'time'"