
{"id":15783,"date":"2014-05-03T16:30:22","date_gmt":"2014-05-03T16:30:22","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=15783"},"modified":"2014-05-03T16:30:22","modified_gmt":"2014-05-03T16:30:22","slug":"how-to-write-a-shell-script-to-find-the-greatest-among-three-numbers","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2014\/05\/03\/how-to-write-a-shell-script-to-find-the-greatest-among-three-numbers\/","title":{"rendered":"How to write a shell script to find the greatest among three numbers ?"},"content":{"rendered":"<pre>\n#!\/bin\/bash\n#\n# Linux Shell Scripting Tutorial 1.05r3, Summer-2002\n#\n# Written by Vivek G. Gite &lt;vivek@nixcraft.com&gt;\n# modified by Jeffrin Jose T. &lt;ahiliation@yahoo.co.in&gt;\n# Latest version can be found at http:\/\/www.nixcraft.com\/\n#\n# Q2. Script to find out biggest number\n#\n# Algo:\n# 1) START: Take three nos as n1,n2,n3.\n# 2) Is n1 is greater than n2 and n3, if yes\n# print n1 is bigest no goto step 5, otherwise goto next step\n# 3) Is n2 is greater than n1 and n3, if yes\n# print n2 is bigest no goto step 5, otherwise goto next step\n# 4) Is n3 is greater than n1 and n2, if yes\n# print n3 is bigest no goto step 5, otherwise goto next step\n# 5) END\n#\n#\n\nif [ $# -ne 3 ]\nthen\necho \"$0: number1 number2 number3 are not given\" &gt;&amp;2\nexit 1\nfi\nn1=$1\nn2=$2\nn3=$3\nif [ $n1 -gt $n2 ] &amp;&amp; [ $n1 -gt $n3 ]\nthen\necho \"$n1 is the Biggest number\"\nelif [ $n2 -gt $n1 ] &amp;&amp; [ $n2 -gt $n3 ]\nthen\necho \"$n2 is the Biggest number\"\nelif [ $n3 -gt $n1 ] &amp;&amp; [ $n3 -gt $n2 ]\nthen\necho \"$n3 is the Biggest number\"\nelif [ $1 -eq $2 ] &amp;&amp; [ $1 -eq $3 ] &amp;&amp; [ $2 -eq $3 ]\nthen\necho \"All the three numbers are equal\"\nelse\necho \"I can not figure out which number is bigger\"\nfi\n\n#\n# .\/ch.sh: vivek-tech.com to nixcraft.com referance converted using this tool\n# See the tool at http:\/\/www.nixcraft.com\/uniqlinuxfeatures\/tools\/\n#\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/bash # # Linux Shell Scripting Tutorial 1.05r3, Summer-2002 # # Written by Vivek G. Gite &lt;vivek@nixcraft.com&gt; # modified by Jeffrin Jose T. &lt;ahiliation@yahoo.co.in&gt; # Latest version can be found at http:\/\/www.nixcraft.com\/ # # Q2. Script to find out biggest number # # Algo: # 1) START: Take three nos as n1,n2,n3. # 2) Is &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2014\/05\/03\/how-to-write-a-shell-script-to-find-the-greatest-among-three-numbers\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to write a shell script to find the greatest among three numbers ?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[83,91],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15783"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=15783"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15783\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=15783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=15783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=15783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}