ls

List the files in a directory.

Signature

> ls ...pattern(s) --all --long --short-names --full-paths --du --directory

Parameters

  • ...pattern(s): the glob pattern(s) to use
  • --all: Show hidden files
  • --long: List all available columns for each entry
  • --short-names: Only print the file names and not the path
  • --full-paths: display paths as absolute paths
  • --du: Display the apparent directory size in place of the directory metadata size
  • --directory: List the specified directory itself instead of its contents

Examples

List all files in the current directory

> ls

List all files in a subdirectory

> ls subdir

List all files with full path in the parent directory

> ls -f ..

List all rust files

> ls *.rs

List all rust files and all toml files

> ls *.rs *.toml

List all files and directories whose name do not contain 'bar'

> ls -s | where name !~ bar

List all dirs in your home directory

> ls ~ | where type == dir

List all dirs in your home directory which have not been modified in 7 days

> ls -s ~ | where type == dir && modified < ((date now) - 7day)

List given paths, show directories themselves

> ['/path/to/directory' '/path/to/file'] | each { |it| ls -D $it } | flatten