Logical Operators in bash script(And, OR, NOT)

හරි මම ඔයාලට කියල දෙන්නම් අද කොහොමද BASH Script වලදි Logical expression use කරන්නෙ කියලා..

code එක පැහදිලි මදිනම් මෙට්තනින් බලන්න - https://lankadevelopers.com/topic/406/logical-operators-in-bash-script-and-or-not

#!/bin/bash

echo "Enter marks :"#user ගෙන් input එක ඉල්ලන්න
read mark #input එක ගන්න

if [ $mark -ge 80  -a $mark -le 100 ]#enter කරපු mark එක 80ට වඩා වැඩිද(-ge 80) ඒ වගේම (-a) 100ට වඩා අඩුද(-la 100)
then #එහෙමනම්
echo "A"#A කියල print කරන්න
elif [ $mark -ge 60 -a $mark -le 79 ]
then
echo "B"
elif [ $mark -ge 40 -a $mark -le 59 ]
then
echo "C"
elif [ $mark -ge 20 -a $mark -le 39 ]
then
echo "D"
elif [ $mark -ge 10 -a $mark -le 19 ]
then
echo "E"
else
echo "Invalid mark"
fi

Comments

Popular posts from this blog

How to copy and move files on linux(Linux terminal එක use කරල file copy කරමු)

File Test Operators