How to batch-processing numerous shell scripts?

How to batch-processing numerous shell scripts?
how to record the result of all the scripts as a report? then, I can analysis the process result.

I want to process numerous shell scripts in my working directory:
the directory name is consistent with shell scripts name, that is to say, CLI001.sh is in the directory named CLI001, and so forth.

e.g.:The numerous shell scripts named: CLI001.sh, CLI002.sh,...

Below is the code I created:

#!/bin/bash
 
for i in CLI*
do
        cd `echo $i`
        pwd
        eval ./*.sh
        cd ..
done

Although you did not mention that something went wrong I suppose that
your script has problems with the eval statement, which expects a shell command
instead of a script filename. You may try something like this:

#!/bin/bash
for i in CLI*
do
    test -d "$i" && cd "$i" || continue
    pwd
    test -f "$i.sh" && sh "$i.sh"
    cd ..
done
1 Like

@hfreyer, thanks for your suggestion, it works.