Lanka Developers Community

    Lanka Developers

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

    DECISION MAKING IN SHELL SCRIPTS(Write a shell script to determine whether a given number is either positive or negative)

    Linux
    bash linuxfoundation linux
    4
    4
    591
    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 binurayeshan

      මම අද ඔයාලට කියල දෙන්නෙ කොහොමද shell scripting පාවිච්චි කරල DECISION MAKING simple programme එකක් ලියන්නෙ කියල.:male-technologist:

      මේ link වලින් ගිහින් ඔයාලට bash script ගැන කලින් කරපු post බලාගන්න පුලුවන්..

      Lets talk about bash script - https://lankadevelopers.com/topic/371/lets-talk-about-bash-script

      First bash script - https://lankadevelopers.com/topic/372/first-bash-script

      Sum of two numbers in bash script - https://lankadevelopers.com/topic/377/sum-of-two-numbers-in-bash-script

      Bash script Array introduction - https://lankadevelopers.com/topic/386/bash-script-array-introduction

      ඔයාලට කියල දුන්න විදියට .sh File එකක් හදාගන්න. දැන් ඔයාලා මෙන්න මේ code එක ඔයාලගෙ script එකේ ලියන්න.

      #!/bin/bash
      
      echo "Enter mark :" 
      read number #ඔයාගේ mark එක read කරනව 
      
      if [ $number -lt 0 ]# මේ කියන්නෙ enter කරපු mark එක less than(අඩුයිනම්) 0 ට වඩා
      then #එහෙනම්
      	echo "Negetive" #negative කියල print කරන්න
      
      elif [ $number -gt 0 ] # මේ කියන්නෙ enter කරපු mark එක greater than(වැඩියිනම්) 0 ට වඩා
      then #එහෙනම්
      	echo "Positive"  #Positive කියල print කරන්න
      
      else #ඒ දෙකම නෙමෙයිනම් 
      	echo "Neither Positive nor negative" 
      fi
      
      

      :relaxed:
      0_1570151873514_Screen Shot 2019-10-04 at 6.47.49 AM.png

      1 Reply Last reply Reply Quote 4
      • root
        root Linux Help last edited by

        Fatta bro

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

          patta brother

          1 Reply Last reply Reply Quote 1
          • dev_lak
            dev_lak last edited by

            thanks bro

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

            1
            Online

            3.7k
            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

            | |