ls
Ls used to display everything in some directory, by default ls
doesn’t show
hidden (started with .
) files and directories.
ls
is one of most popular GNU Utilities tool.
List of common commands:
- List files in directory:
ls <dir>
- Display everything in
<dir>
, including hidden files:ls -a <dir>
- Display all files, along with the size and timestamp:
ls -lh <dir>
- Display files, sorted by size:
ls -S <dir>
- Display directories only:
ls -d */ <dir>
- Display directories only, include hidden:
ls -d .*/ */ <dir>
- Display files sorted by create time:
ls -lt
- To display files in a single column, without details:
ls -1
- Show all the subtree files (Recursive Mode):
`ls -R
I also use “modern” replacement - eza, with dynamic
aliases in my Zsh config (~/.zshrc
file):
if (( $+commands[eza] )); then
IGNORE_GLOB="UnrealEngine"
alias eza="eza --group-directories-first --git";
alias l="eza -bl -I $IGNORE_GLOB";
alias ll="eza -abghilmu -I $IGNORE_GLOB";
alias la="LC_COLLATE=C eza -ablF -I $IGNORE_GLOB";
alias lm='ll --sort=modified'
alias tree='eza --tree'
alias treel='eza --color=always --tree|less'
else
alias l='ls'
alias ll='ls -la' # long listing format
alias la='ls -d .* --color=auto' # hidden files
alias lm='ls -lt' # by modification date, newest first
fi
ls
aliases flashcards
- Standard listing alias:
l
- Detailed listing alias:
ll
- Alias to list hidden files:
la
- Alias to list with sorting by modification date:
lm