Jeel Jeel - 3 months ago 10
Bash Question

Shell Script for searching Makefile recursively in directories

I need to build a shell script on debian based OS to recursively browse and identify which Folders have Makefile present. If present then build the package. If not present then just list those folders. The catch here as shown below is I need to browse only one folder below the parent folder (ABC) and check if makefile is present under Folder1, Folder 2...etc and not to go into the sub directories of Folder1 (not to look for Makefile under folders Folder1.1, Folder 1.2, Folder2.1 etc). Looking for some tips how to loop only one level and then exit back to folder ABC and start the search.

ABC---
|---Folder1
| |-------Makefile
|-------Folder1.1
|-------Folder1.2

|---Folder2
| |-------Somefile
|-------Folder2.1
|-------Folder2.2
|---FolderN
| |-------Makefile
|-------FolderN.1
|-------FolderN.2

Answer

As answered by Karthikraj in above comments. This helped

find . -maxdepth 2 -type f -iname 'makefile'
Comments