0

I have a test tree that goes like this :

user@host :~/test/ $ tree
.
└── 1st
    ├── 1st.json
    └── 2nd
        ├── 2nd.json
        └── 3rd
            └── 4th
                ├── 4th.json
                └── 5th
                    └── 5th.json

5 directories, 4 files

And I get this behavior from find :

user@host :~/test/ $ find . -name *.json
./1st/2nd/3rd/4th/4th.json
./1st/2nd/3rd/4th/5th/5th.json
./1st/2nd/2nd.json
./1st/1st.json

user@host :~/test/1st $ find . -name *.json
./1st.json

user@host :~/test/1st/2nd $ find . -name *.json
./2nd.json

user@host :~/test/1st/2nd/3rd $ find . -name *.json
./4th/4th.json
./4th/5th/5th.json

user@host :~/test/1st/2nd/3rd/4th $ find . -name *.json
./4th.json

user@host :~/test/1st/2nd/3rd/4th/5th $ find . -name *.json
./5th.json

The command seems to be recursive only if find doesn't find filenames that match the pattern in the current directory.

Removing . in the command gives the same output each time.

Is it normal behavior. And in both cases, is there a way to modify this and how ?

PS : Also =>

user@host :~/test/1st $ find -mindepth 0 -name *.json
./1st.json
user@host :~/test/1st $ find -mindepth 1 -name *.json
./1st.json
user@host :~/test/1st $ find -mindepth 2 -name *.json
user@host :~/test/1st $ find -mindepth 3 -name *.json
user@host :~/test/1st $ find -mindepth 4 -name *.json
user@host :~/test/1st $ find -mindepth 5 -name *.json

Atralb
  • 280

0 Answers0