findコマンドがディレクトリも返すのはなぜですか?

findコマンドがディレクトリも返すのはなぜですか?

空のディレクトリを作成し、端末で次のコマンドを実行しました。

mael@mael-HP:~/repertoireVide$ mkdir -p a/b/c
mael@mael-HP:~/repertoireVide$ mkdir -p a/a/b
mael@mael-HP:~/repertoireVide$ mkdir -p b/a
mael@mael-HP:~/repertoireVide$ echo "c" > a/c
mael@mael-HP:~/repertoireVide$ echo "c" > c

ツリーには、次の mael@mael-HP:~/repertoireVide$ ツリーが表示されます。

.
├── a
│   ├── a
│   │   └── b
│   ├── b
│   │   └── c
│   └── c
├── b
│   └── a
└── c

7 directories, 2 files

次のfindコマンドがこれを出力するのはなぜですか?

mael@mael-HP:~/repertoireVide$ find .
.
./a
./a/a
./a/a/b
./a/c
./a/b
./a/b/c
./c
./b
./b/a

find次のようにファイルが指定されたディレクトリにあると仮定しないでくださいman find

find - search for files in a directory hierarchy

すべてのサブディレクトリがファイルと共にリストされているのはなぜですか?

ありがとうございます。

ベストアンサー1

目次はい文書。検索では、次のオプションを使用して一般的な種類のファイルを見つけることができます-type

find . -type f ...

またはディレクトリタイプファイルの場合:

find . -type d ...

-タイプティー

ファイルが指定されたタイプの場合は真です。可能なファイル形式は次のとおりです。

b       block special
c       character special
d       directory
f       regular file
l       symbolic link
p       FIFO
s       socket

おすすめ記事