Reverse rows and columns of matrix using Shell Script

Reverse rows and columns of matrix

 

Problem Statement : Write a shell script to Reverse rows and columns of matrix using Shell Script.

In Reverse rows and columns of matrix using Shell Script program user will be asked to enter number of rows and columns in the matrix. After that user need to enter each element one by one to the program. Reversed matrix of Reverse rows and columns of matrix will be printed on the screen.

Reverse rows and columns of matrix using Shell Script Code

[button style=”large green  embossed” link=”https://sites.google.com/site/codesgeeks/codesgeek_1/Reverse%20rows%20and%20columns%20of%20matrix%20using%20Shell%20Script.sh” target=”_blank” ]Shell Script Code Download[/button]

Reverse rows and columns of matrix using Shell Script Output

Sample Output 1

mint@mint ~ $ ./matrix.sh
Enter Number of rows
2
Enter Number of columns
2
Enter elements
1
3
2
4
Transpose of a Matrix
1
2
3
4

Sample Output 2

mint@mint ~ $ ./matrix.sh
Enter Number of rows
3
Enter Number of columns
3
Enter elements
1
3
2
4
2
5
6
3
1
Transpose of a Matrix
1
4
6

3
2
3

2
5
1

Sample Output 3

mint@mint ~ $ ./matrix.sh
Enter Number of rows
2
Enter Number of columns
3
Enter elements
1
3
2
4
5
6
Transpose of a Matrix
1
4

3
5

2
6