i am inside a directory called TestJ. Inside this directory i have many folders like MSC1,MSC2 … MSC19, HLR1,HLR2 .. ,SGSN1,SGSN2 .. .Now inside each of these directories is a script ALARMS.sh. What i want to do is loop through all these folders and execute ALARMS.sh in each folder . what my present code does is use this
ls -d SGSN* > temp.txt
while read sgsn_line;do
echo $sgsn_line
cd $sgsn_line
ALARMS.sh
cd ..
done < temp.txt
ls -d HLR* > temp.txt
while read hlr_line;do
echo $hlr_line
cd $hlr_line
ALARMS.sh
cd ..
done < temp.txt
ls -d MSC* > temp.txt
while read msc_line;do
echo $msc_line
cd $msc_line
ALARMS.sh
cd ..
done < temp.txt
rm temp.txt
But i want to do the same job without listing the folders in any file. like for example we can loop through files in a given folder using for file in *.txt. I would like to be able to do the same for folders(only folders).
Use like below…