Issue
In order to find a file by name, I have this command:
find . /home/XYZ/ -name '*abc*'
But it shows results in the directory XYZ and its subdirectories. I only need to search inside the specific folder "XYZ", not in the subdirectories.
How can I accomplish this?
Solution
find . XYZ/ -maxdepth 1 -name *abc*
OUTPUT
find . XYZ/ -maxdepth 1 -name *abc*
XYZ/abc.txt
find . XYZ/ -name *abc*
./XYZ/abc.txt
./XYZ/tuv/123abc
XYZ/abc.txt
XYZ/tuv/123abc
man find
-maxdepth levels
Descend at most levels (a non-negative integer) levels of directories below the starting-points. Using
-maxdepth 0 means only apply the tests and actions to the starting-points themselves.
Answered By - atl Answer Checked By - Pedro (WPSolving Volunteer)