{"id":2262,"date":"2017-12-08T06:01:30","date_gmt":"2017-12-08T06:01:30","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=2262"},"modified":"2020-01-09T10:00:17","modified_gmt":"2020-01-09T10:00:17","slug":"script-to-find-out-biggest-number-from-given-three-nos","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/script-to-find-out-biggest-number-from-given-three-nos\/","title":{"rendered":"Script to find out biggest number from given three nos"},"content":{"rendered":"<p><strong>rajeshkumar created the topic: Script to find out biggest number from given three nos<\/strong><\/p>\n<p>Write Script to find out biggest number from given three nos. Nos are supplies as command line argument. Print error if sufficient arguments are not supplied.<\/p>\n<p><code><br \/>\n#!\/bin\/bash<br \/>\n#<br \/>\n# Linux Shell Scripting Tutorial 1.05r3, Summer-2002<br \/>\n#<br \/>\n# Written by Vivek G. Gite <vivek@nixcraft.com><br \/>\n#<br \/>\n# Latest version can be found at www.nixcraft.com\/<br \/>\n#<br \/>\n# Q2. Script to find out bigest number<br \/>\n#<br \/>\n# Algo:<br \/>\n# 1) START: Take three nos as n1,n2,n3.<br \/>\n# 2) Is n1 is greater than n2 and n3, if yes<br \/>\n# print n1 is bigest no goto step 5, otherwise goto next step<br \/>\n# 3) Is n2 is greater than n1 and n3, if yes<br \/>\n# print n2 is bigest no goto step 5, otherwise goto next step<br \/>\n# 4) Is n3 is greater than n1 and n2, if yes<br \/>\n# print n3 is bigest no goto step 5, otherwise goto next step<br \/>\n# 5) END<br \/>\n#<br \/>\n#<\/p>\n<p>if [ $# -ne 3 ]<br \/>\nthen<br \/>\necho \"$0: number1 number2 number3 are not given\" >&2<br \/>\nexit 1<br \/>\nfi<br \/>\nn1=$1<br \/>\nn2=$2<br \/>\nn3=$3<br \/>\nif [ $n1 -gt $n2 ] && [ $n1 -gt $n3 ]<br \/>\nthen<br \/>\necho \"$n1 is Bigest number\"<br \/>\nelif [ $n2 -gt $n1 ] && [ $n2 -gt $n3 ]<br \/>\nthen<br \/>\necho \"$n2 is Bigest number\"<br \/>\nelif [ $n3 -gt $n1 ] && [ $n3 -gt $n2 ]<br \/>\nthen<br \/>\necho \"$n3 is Bigest number\"<br \/>\nelif [ $1 -eq $2 ] && [ $1 -eq $3 ] && [ $2 -eq $3 ]<br \/>\nthen<br \/>\necho \"All the three numbers are equal\"<br \/>\nelse<br \/>\necho \"I can not figure out which number is biger\"<br \/>\nfi<\/p>\n<p>#<br \/>\n# .\/ch.sh: vivek-tech.com to nixcraft.com referance converted using this tool<br \/>\n# See the tool at www.nixcraft.com\/uniqlinuxfeatures\/tools\/<br \/>\n#<\/p>\n<p><\/code><br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>rajeshkumar created the topic: Script to find out biggest number from given three nos Write Script to find out biggest number from given three nos. Nos are supplies as command&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[454],"tags":[278],"class_list":["post-2262","post","type-post","status-publish","format-standard","hentry","category-shell-script","tag-script"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=2262"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2262\/revisions"}],"predecessor-version":[{"id":2263,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2262\/revisions\/2263"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=2262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=2262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=2262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}