#!/bin/bash ############################################################ ### Script to execute multiple scripts in subdirectories ### ############################################################ # Name of the file to execute in all subdirectories script_name="launchPEM.sh" #script_name="kill_launchPEM.sh" #script_name="clean.sh" #script_name="modify_startfi_orbit.sh" # Name of the template directory to skip tempdir_name="Template" # Traverse all subdirectories, excluding the template i=0 for dir in */; do if [ "$dir" == "$tempdir_name/" ]; then continue fi if [ -f "$dir/$script_name" ]; then echo "Executing $script_name in $dir..." pushd "$dir" > /dev/null ./$script_name popd > /dev/null ((i++)) fi done echo "Everything is executed: $i executions in total!"