16 January 2012

Shell Script to Display numbers Using Array

2 comments

Q. How to use array in Bash for taking input and displaying it


Ans:

#!/bin/bash
for((i=0;i<5;i++))
do
echo "enter `expr $i + 1` number"
read arr[$i]
done
echo "the numbers you hav entered are"
for((i=0;i<5;i++))
do
echo ${arr[$i]}
done

Output


use of array in bash

Enjoy :)


If You Liked This Post Please Take a Time To Share This Post

You May Also Like...

2 comments:

  1. Post was great—writing elevated it to the next level. This article of CPS Test is worth reading. With time, patience, and a little effort, CPS Test helps build one of the fastest and most useful hand skills online.

    ReplyDelete