Home > Enterprise >  Looping over dirs using `find . -depth 1 -type d`
Looping over dirs using `find . -depth 1 -type d`

Time:09-28

I've been given a script to run, but it produces an error when calling find . -depth 1 -type d. It produces the following error,

find: paths must precede expression: `1'

This is the line in which it fails,

for dir in `find . -depth 1 -type d`
do
    ....

I have tried quite a few things without success. And I don't really see why it gives the error since it seems to me at least, that the paths does indeed precede the "1".

CodePudding user response:

Not all find implementations support -depth 1. A portable alternative would be:

find . ! -name . -type d -prune
  • Related