Skip to main content
added 360 characters in body
Source Link
Torin
  • 1.8k
  • 1
  • 11
  • 17

The find utility supports the option -maxdepth

-maxdepth levels
Descend at most levels (a non-negative integer) levels of directories below the starting-points. -maxdepth 0 means only apply the tests and actions to the starting-points themselves.

To restrict find to the specified directory, you can add the option -maxdepth 1.


If you're trying to list all regular files *.partial at depth 2 with an output similar to that in your question, you could try a command such as

 find . -mindepth 2 -maxdepth 2 -type f -name '*.partial' -printf '%h\t./%f\n' 

which could give an output similar to

./b ./file2.partial ./b ./file3.partial ./a ./file1.partial 

The find utility supports the option -maxdepth

-maxdepth levels
Descend at most levels (a non-negative integer) levels of directories below the starting-points. -maxdepth 0 means only apply the tests and actions to the starting-points themselves.

To restrict find to the specified directory, you can add the option -maxdepth 1.

The find utility supports the option -maxdepth

-maxdepth levels
Descend at most levels (a non-negative integer) levels of directories below the starting-points. -maxdepth 0 means only apply the tests and actions to the starting-points themselves.

To restrict find to the specified directory, you can add the option -maxdepth 1.


If you're trying to list all regular files *.partial at depth 2 with an output similar to that in your question, you could try a command such as

 find . -mindepth 2 -maxdepth 2 -type f -name '*.partial' -printf '%h\t./%f\n' 

which could give an output similar to

./b ./file2.partial ./b ./file3.partial ./a ./file1.partial 
Source Link
Torin
  • 1.8k
  • 1
  • 11
  • 17

The find utility supports the option -maxdepth

-maxdepth levels
Descend at most levels (a non-negative integer) levels of directories below the starting-points. -maxdepth 0 means only apply the tests and actions to the starting-points themselves.

To restrict find to the specified directory, you can add the option -maxdepth 1.