I am trying to automate (using bash script)creation of JHFS+ formatted,DMG file on a macOS. The script should be able to intake user supplied:
- size of the DMG in GB's
- destination of the DMG
- type of filesystem (HFS+,JHFS+,APFS,FAT32,ExFAT or UDF)
- volume name
- the name of the DMG to be created.
I used the following:
date
read -p "Enter the size of the DMG: " size
read -e -p "Enter the destination of the DMG: " dest
read -p "Enter the filesystem (HFS+,JHFS+,APFS,FAT32,ExFAT or UDF) :" fs
read -p "Enter the Volume name :" volname
read -p "Enter the name of the DMG:" name
hdiutil create -fs {"$fs"} -size "$size" -volname "{$volname}" "{$dest\/$name}"
exit
Issue is when the script is executed,with size mentioned as "1g" (1GB),I get the following error:
hdiutil: create failed - Invalid argument
Suggestions to improve the script are welcome.Thanks in advance :)