Bash script to create a replica set

One other thing, if this is to set up test systems, you might want to look at mlaunch is part of the bigger mtools set of tools and is maintained by @Stennie_X!

mlaunch makes setting up test clusters/replica sets a breeze. These systems will all run on the same machine so it’s not for production, but for testing having multiple mongod instances on the same host is not a big deal.

Again it all depends on what you’re trying to accomplish on whether this makes sense for you to use or not.