首页 > 解决方案 > 选择字符串块

问题描述

#!/bin/bash
#
dm1="test1@gmail.com, test2@gmail.com, test3@gmail.com"
dm2="test4@gmail.com, test5@gmail.com, test6@gmail.com"
dm3="test7@gmail.com, test8@gmail.com, test9@gmail.com"
#
read -p "type: dm1, dm2 or dm3 to select: " blocks

我需要变量 $blocks 不包含字符串 dm1、dm2 或 dm3,而是包含 dm1、dm2 或 dm3 变量的内容,以重定向到 mutt 以发送电子邮件

标签: bash

解决方案


dm1="test1@gmail.com, test2@gmail.com, test3@gmail.com"
blocks="dm1"
echo "${!blocks}"

Output:

test1@gmail.com, test2@gmail.com, test3@gmail.com

推荐阅读