0

Dear experts i have a small problem...i am trying to run multiple shell scripts having same extension(.sh) in one go, which are present inside a directory. In so far i wrote a common script like as below. But problem is that it does not finish running instead it keeps running.I am unable to find out where the problems persist.I hope some expert may look into it. my small code is as below. if i do something like bash scriptone.sh, bash scriptkk.sh it works fine but i donot want manual way to do it.Thanks

 #!/bin/sh
 for f in *.sh; do
  bash "$f" -H 
done
0

If the common script you reference in your question also has the .sh extension, and exists in the same directory as all the other scripts you are trying to execute, then you're going to infinitely loop over all the .sh files, because you'll be calling your common script recursively.

You can resolve this in a number of ways, e.g., move the common script to a different location, or put all the non-common scripts in a specific subdirectory and modify your common script to find them there.

  • Thanks, I will try – Tom Hayes Jul 15 '20 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.