I created a empty directories, and executed the following in the terminal

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

Tree shows the following mael@mael-HP:~/repertoireVide$ tree

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

7 directories, 2 files

Why does the following find command output this

mael@mael-HP:~/repertoireVide$ find .

Isn't find only suppose the look for FILES inside the specified directories, as per the man find:

find - search for files in a directory hierarchy

Why are all the sub-directories listed with the files ?



1 Answer 1


Directories are files. Find can look for regular-type files using the -type option:

find . -type f ...

Or for directory type files:

find . -type d ...

-type t

True if the file is of the specified type. Possible file types are as follows:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .