我想映射,例如,4到’Apr'(月份名称的3个字符缩写)
试试这个 :
MONTHS=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) echo ${MONTHS[3]}
或者按照@ potong的建议(月份号和索引之间有1-1对应关系)
MONTHS=(ZERO Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) echo ${MONTHS[4]}