Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

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

    Linux
    bash scripting
    2
    2
    390
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • binurayeshan
      binurayeshan Linux Help last edited by

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

      #!/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
      
      

      :ghost:

      0_1570683194188_Screenshot 2019-10-10 at 10.23.09.png

      1 Reply Last reply Reply Quote 1
      • Nubelle
        Nubelle Web Development last edited by

        patta bro

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post

        2
        Online

        3.6k
        Users

        1.3k
        Topics

        5.3k
        Posts

        • Privacy
        • Terms & Conditions
        • Donate

        © Copyrights and All right reserved Lanka Developers Community

        Powered by Axis Technologies (PVT) Ltd

        Made with in Sri Lanka

        | |