Linux program, display even number in given range, command line parameter, programming, file, practical file

https://www.knowsh.com > Notes > Linux > Linux program to display even number in range
Priya Linux program to display even number in range Linux program to display even number in given range. Range is given as command line parameter.

Linux program to display even number in range

Linux program to display even number in range

Linux program to display even number in range (Linux)

Introduction (Descriptive)

Linux program to display even number in given range. Range is given as command line parameter.

Details

#TO DISPLAY EVEN NUMBERS BETWEEN A GIVEN RANGE &
#RANGE IS GIVEN AS COMMAND LINE PARAMETER

if [ -z $1 -o -z $2 ]
then
  echo "Ranges are not given"
else
  echo "Even numbers between $1 and $2 are : "
  for((i=$1;i<=$2;i++))
  do
    rem=`expr $i % 2`
    if [ $rem -eq 0 ]
    then
      echo "$i"
    fi
  done
fi

 


About knowsh.com

We are tring to provide a common plateform to the students and professionals to share their knowledge among others because knowledge is the only thing that increase when it is shared.

Contact links

Follow Us On