I would like to count successfully executed files, but I can't get it to go.
This is what I have:
successfulScripts=0
allScripts=0
commandline=$(find . -name "*.sh" -exec '{}' \;)
if [ $commandline -gt 0 ]; then
successfulScripts=$(($successfulScripts+1))
allScripts=$(($allScripts+1))
else
allScripts=$(($allScripts+1))
fi
echo "$successfulScripts out of $allScripts scripts were executed successfully"
I don't mind if content of a script is also shown, but is there any way to despise it?
Best Answer
You could just let
find
use the value returned by the script. egwill execute the script and then
-print
will only print the names of those scripts which return 0. The output will be interleaved with the output of the scripts, so maybe you just want to redirect the script output elsewhere. On the other hand, if you want to print a pretty summary at the end, maybe you're looking for something like: