ls

Displays files and directories. There are many options as shown below, so it is impossible to learn them all. There are so many options that it is impossible to learn them.

NAME
     ls -- list directory contents

SYNOPSIS
     ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...

github

  • The file in jupyter notebook format on github is here.

google colaboratory

  • To run it in google colaboratory here ls_nb.ipynb)

Environment

The author’s OS is macOS, and the options are different from those of Linux and Unix commands.

When you actually run the command, you should not use the leading ! and %%bash in the first line.

!sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G2022
!bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.

Example usage

No options. Displays the files in the directory directly below.

%%bash
ls
ls_nb.ipynb
ls_nb.md
ls_nb.py

The most commonly used is ls -al. This is an alias setting. It is in a list format and will also show you hidden files starting with a dot.

ls -al
total 24
drwxr-xr-x 6 hiroshi staff 192 7 3 18:50 [34m.[m[m/
drwxr-xr-x 24 hiroshi staff 768 7 3 18:36 [34m. [m[m/
drwxr-xr-x 3 hiroshi staff 96 6 24 19:46 [34m.ipynb_checkpoints[m[m/
-rw-r--r-- 1 hiroshi staff 2967 7 3 18:49 ls_nb.ipynb
-rw-r--r-- 1 hiroshi staff 1052 7 3 18:49 ls_nb.md
-rw-r--r-- 1 hiroshi staff 970 7 3 18:49 ls_nb.py

Typical options

  • a = all
  • l == list