{"id":2264,"date":"2017-12-08T06:03:46","date_gmt":"2017-12-08T06:03:46","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=2264"},"modified":"2022-12-23T05:32:32","modified_gmt":"2022-12-23T05:32:32","slug":"shell-script-that-will-add-two-nos","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/shell-script-that-will-add-two-nos\/","title":{"rendered":"Shell Bash Scripting: Assignment &#038; Excercise \u2013 17"},"content":{"rendered":"<p><strong>rajeshkumar created the topic: Shell script that will add two nos<\/strong><br \/>\nHow to write shell script that will add two nos, which are supplied as command line argument, and if this two nos are not given show error and its usage<\/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 &lt;vivek@nixcraft.com&gt;<br \/>\n#<br \/>\n# Latest version can be found at www.nixcraft.com\/<br \/>\n#<br \/>\n# Q1.Script to sum to nos<br \/>\n#<\/code><\/p>\n<p>if [ $# -ne 2 ]<br \/>\nthen<br \/>\necho &#8220;Usage &#8211; $0 x y&#8221;<br \/>\necho &#8221; Where x and y are two nos for which I will print sum&#8221;<br \/>\nexit 1<br \/>\nfi<br \/>\necho &#8220;Sum of $1 and $2 is `expr $1 + $2`&#8221;<br \/>\n#<br \/>\n# .\/ch.sh: vivek-tech.com to nixcraft.com referance converted using this tool<br \/>\n# See the tool at<a href=\"http:\/\/www.nixcraft.com\/uniqlinuxfeatures\/tools\/\" target=\"_blank\" rel=\"noopener\"> www.nixcraft.com\/uniqlinuxfeatures\/tools\/<\/a><br \/>\n#<\/p>\n<p>Regards,<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: Shell script that will add two nos How to write shell script that will add two nos, which are supplied as command line argument, and if&#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-2264","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\/2264","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=2264"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2264\/revisions"}],"predecessor-version":[{"id":32403,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/2264\/revisions\/32403"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=2264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=2264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=2264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}