It really isn't my job to teach you how to use the CLI, but, since I needed a five minute break anyway...
Code:
id = `calibredb add test.html --duplicates | grep "Added book ids" | tail -n1 | cut -d":" -f2`
calibredb add_format $id someotherformat.epub
ebook-meta file.mobi | grep '^Title' | head -n1 | cut -d":" -f 2