Bash Script to create a new skeleton module in Magento 2

Add this script to the end of you ~/.bashrc file

createmodule() {
    cd /var/www/magento2/src/app/code # replace with your magento codebase app/code directory
    mkdir -p "$1"/"$2"/etc
    echo "<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Module/etc/module.xsd\">
    <module name=\"$1_$2\">
    </module>
</config>
" > "$1"/"$2"/etc/module.xml
    echo "<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    '$1_$2',
    __DIR__
);
" > "$1"/"$2"/registration.php
}

Run
source ~/.bashrc
in your terminal to apply the change
Then run
createmodule [VendorName] [ModuleName]

It should create VendorName/ModuleName/etc/module.xml and VendorName/ModuleName/registration.php with necessary code