Correctly escape strings for bash when writing metadata result file.