Loop through all folders and executing script

Use full path of your parent directory(in my case apps directory located in my home directory) and remove one extra command(cd ..)

for dir in ~/apps/*;
  do 
     [ -d "$dir" ] && cd "$dir" && echo "Entering into $dir and installing packages"
  done;

See screenshot: with cd .. command and using apps/*

enter image description here

See screenshot: without cd .. command and using ~/apps/*

enter image description here


You can use find along with exec for this propose. Your install.sh should be

#!/bin/bash
find ./apps -type d -exec echo Entering into {} and installing packages \; 

replace text after -exec with your command

for example

#!/bin/bash
find ./apps -type d -exec touch {}/test.txt  \;  

It will loop through app and all its sub-directories and will create a text.txt file