0

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 .
.
./a
./a/a
./a/a/b
./a/c
./a/b
./a/b/c
./c
./b
./b/a

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 ?

Thanks.

asked Oct 25, 2019 at 21:09
2

1 Answer 1

5

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
answered Oct 25, 2019 at 21:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.