#!/bin/bash emp_info=( aaa 13800000000 aaa@qq.com bbb 13800000001 bbb@qq.com ccc 13800000002 ccc@qq.com ddd 13800000003 ddd@qq.com eee 13800000004 eee@qq.com ) for i in ${!emp_info[@]} do if [ `expr $i % 3` = "2" ] # get mail addr then name=${emp_info[`expr $i - 2`]} mailaddr=${emp_info[$i]} mobile=${emp_info[`expr $i - 1`]} echo $name $mobile $mailaddr fi done