Bash のディレクトリを一覧表示する
Aashish Sunuwar
2022年3月24日

Bash のファイルとフォルダーのリストを見てみましょう。
ls
コマンドを使用して、Bash のディレクトリを一覧表示する
ls
コマンドを使用して、Bash の現在のディレクトリにあるアイテムを一覧表示します。
ls
出力:
some_dir/
├── myFile1.txt
├── myFile2.txt
├── myFile3.txt
├── child_dir01/
├── child_dir02/
└── child_dir03/
ただし、*/
を使用してディレクトリを出力することはできます。これは、すべてのディレクトリが -d
オプションで/
で終了し、ディレクトリの内容ではなく名前のみが表示されるようにするためです。
ls -d */
出力:
some_dir/
├── child_dir01/
├── child_dir02/
└── child_dir03/
関連記事 - Bash File
- Bash を使用してファイル拡張子を削除する
- Linux Bash でファイルの行数を求める
- Linux でファイルとフォルダを検索する
- Bash でファイル行を読む
- Bash を使用してファイル名と拡張子を取得する