#!/bin/bash while read row colu; do declare -A arr for i in `seq 1 $row`; do read rows arr+=(["$i"]=$rows) done for i in `seq 1 $colu`; do for j in `seq 1 $row`; do echo -n `echo ${arr[$j]} | cut -d ' ' -f $i` if [ $j -ne $row ]; then echo -n " " fi done printf "\n" done done