Lanka Developers Community

    Lanka Developers

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

    DECISION MAKING IN SHELL SCRIPTS Part 2(කොහොමද Arguments දෙකක් එක්ක වැඩ කරන්නෙ)

    Linux
    bash scripting linux
    3
    3
    646
    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

      හරි මම ඔයාලට කියල දෙන්නම් කොහොමද conditions දෙකක් check කරන්නෙ කියල.
      මෙන්න මේකයි Programm එක. userගෙන් input දෙකක් ගන්නව අරගෙන එයා ඒ දෙකටම inputs දුන්නද නැද්ද කියල check කරනව.

      #!/bin/bash
      
      echo "Enter argument 1 :" #argument 1 එක එන්ටර් කරන්න කියනවා
      read arg1 #User ගෙන් input එක ගන්නවා
      
      echo "Enter argument 2 :"
      read arg2
      
      if [ -n "$arg1" ] #මේ කියන්නෙ arg1 එක මෙකේ value එක Zero නෙමේනම් කියන එක 
      then #එහෙමන්ම්
      	echo "Argument 1 has value"#Argument 1 has value කියල print කරන්න 
      
      elif [ -z "$arg1" ]#මේ කියන්නෙ arg1 එක මෙකේ value එක Zero නම් කියන එක 
      then #එහෙමන්ම්
      	echo "Argument 1 has no value"#Argument 1 has no value කියල print කරන්න
      fi#මේ කියන්නෙ මෙන්න මේ පටන් ගත්ත පලවෙනි dicision එක close කරන්න කියල 
      
      if [ -n "$arg2" ]
      then
      	echo "Argument 2 has value"
      
      elif [ -z "$arg2" ]
      then 
      	echo "Argument 2 has no value"
      fi
      

      :male-technologist: :call_me_hand: :sunglasses:

      0_1570345984519_Screen Shot 2019-10-06 at 12.42.59 PM.png

      මේ 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

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

        ftta bro

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

          fatta mchan

          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

          | |