[Bash Script -1] For rotating two-dimensional matrix

Image

#!/bin/bash

#Here we use the row major representation of a two-dimensional matrix.
#Array ‘x’ is the original matrix and  ‘r’ is the matrix after rotation.
#Matrix rotations in multiples of 90 degrees can be done by calling the rotate function repeatedly.

#perform clockwise-rotation by 90 degrees
rotate () {
t=(“$@”)
let i=0
while [ $i -lt $n ]
do
let j=0
while [ $j -lt $n ]
do
Read More »