{"id":65710,"date":"2021-07-12T04:10:03","date_gmt":"2021-07-12T08:10:03","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/another-example-of-case-and-for-loop-linux-unix-shell-programming-001\/"},"modified":"2021-07-12T04:10:03","modified_gmt":"2021-07-12T08:10:03","slug":"another-example-of-case-and-for-loop-linux-unix-shell-programming-001","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=65710","title":{"rendered":"Another Example of Case and For Loop #Linux\/Unix: Shell Programming &#8211; 001"},"content":{"rendered":"<p>Output First<\/p>\n<p>bash-3.2$ .\/ksh_case_chart.sh<br \/>\nEnter your Number<br \/>\n9<br \/>\n9 * 1 = 9<br \/>\n9 * 2 = 18<br \/>\n9 * 3 = 27<br \/>\n9 * 4 = 36<br \/>\n9 * 5 = 45<br \/>\n9 * 6 = 54<br \/>\n9 * 7 = 63<br \/>\n9 * 8 = 72<br \/>\n9 * 9 = 81<br \/>\n9 * 10 = 90<\/p>\n<p>&#8212;-<br \/>\n???<\/p>\n<p>#!\/bin\/ksh<\/p>\n<p>#example on how to use case and for loop<\/p>\n<p>multi()<br \/>\n{<br \/>\n#clear<br \/>\nfor i in 1 2 3 4 5 6 7 8 9 10<br \/>\ndo<br \/>\necho &#8220;$Y * $i = `expr $Y * $i`&#8221;<br \/>\ndone<br \/>\n}<\/p>\n<p>#take a number from the user ( 1..10)<br \/>\necho &#8220;Enter your Number&#8221;<br \/>\nread X<\/p>\n<p>case &#8220;$X&#8221; in<\/p>\n<p>1)<br \/>\nY=1<br \/>\nmulti<br \/>\n;;<\/p>\n<p>2)<br \/>\nY=2<br \/>\nmulti<br \/>\n;;<\/p>\n<p>3)<br \/>\nY=3<br \/>\nmulti<br \/>\n;;<\/p>\n<p>4)<br \/>\nY=4<br \/>\nmulti<br \/>\n;;<\/p>\n<p>5)<br \/>\nY=5<br \/>\nmulti<br \/>\n;;<\/p>\n<p>6)<br \/>\nY=6<br \/>\nmulti<br \/>\n;;<\/p>\n<p>7)<br \/>\nY=7<br \/>\nmulti<br \/>\n;;<\/p>\n<p>8)<br \/>\nY=8<br \/>\nmulti<br \/>\n;;<\/p>\n<p>9)<br \/>\nY=9<br \/>\nmulti<br \/>\n;;<\/p>\n<p>10)<br \/>\nY=10<br \/>\nmulti<br \/>\n;;<\/p>\n<p>esac<br \/>\nexit<\/p>\n<p>&#8212;&#8211; From: http:\/\/sitestree.com\/?p=12189<br \/> Categories:Linux\/Unix: Shell Programming &#8211; 001<br \/>Tags:<br \/> Post Data:2018-04-16 18:48:57<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Output First bash-3.2$ .\/ksh_case_chart.sh Enter your Number 9 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 9 * 6 = 54 9 * 7 = 63 9 * 8 = 72 9 * 9 = 81 9 * &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=65710\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1917],"tags":[],"class_list":["post-65710","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":65697,"url":"http:\/\/bangla.sitestree.com\/?p=65697","url_meta":{"origin":65710,"position":0},"title":"Example use of case #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"Example Output: 10 * 1 = 10 10 * 2 = 20 10 * 3 = 30 10 * 4 = 40 10 * 5 = 50 10 * 6 = 60 10 * 7 = 70 10 * 8 = 80 10 * 9 = 90 10 * 10\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65716,"url":"http:\/\/bangla.sitestree.com\/?p=65716","url_meta":{"origin":65710,"position":1},"title":"While Loop Example in Shell Programming. Display a Chart #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 12, 2021","format":false,"excerpt":"Example Output bash-3.2$ .\/while-loop-example.sh Enter your Number 10 10 * 1 = 10 10 * 2 = 20 10 * 3 = 30 10 * 4 = 40 10 * 5 = 50 10 * 6 = 60 10 * 7 = 70 10 * 8 = 80 10 *\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65687,"url":"http:\/\/bangla.sitestree.com\/?p=65687","url_meta":{"origin":65710,"position":2},"title":"Examples of using variables in a Shell Program #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"#!\/bin\/sh #assign value to a variable and print to the screen NAME=\"Justetc\" echo $NAME #Ask the user to enter a Name echo ################################## echo \"enter name\" #read command is used to take input from the user read X #print the value two times to the screen echo $X echo $X\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14157,"url":"http:\/\/bangla.sitestree.com\/?p=14157","url_meta":{"origin":65710,"position":3},"title":"case \u098f\u09b0 \u0985\u09a8\u09cd\u09af \u098f\u0995\u099f\u09bf  \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0 . Example use of case","author":"Sayed","date":"April 16, 2018","format":false,"excerpt":"\u09ab\u09b2\u09be\u09ab\u09b2 bash-3.2$ .\/ksh_case_chart.sh Enter your Number 9 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 9 * 6 = 54 9 * 7 = 63 9 * 8 = 72 9 * 9\u2026","rel":"","context":"In &quot;\u09b6\u09c7\u09b2 \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae\u09bf\u0982 - Shell Programming&quot;","block_context":{"text":"\u09b6\u09c7\u09b2 \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae\u09bf\u0982 - Shell Programming","link":"http:\/\/bangla.sitestree.com\/?cat=1888"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65691,"url":"http:\/\/bangla.sitestree.com\/?p=65691","url_meta":{"origin":65710,"position":4},"title":"Take Two values from the user and do arithmetic operations #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"#!\/usr\/bin\/bash clear echo \"Enter First Number\" read x echo \"Enter Second Number\" read y #does not work for \/bin\/sh (( z = $x + $y )) (( a = $x - $y )) (( b = $x * $y )) (( c = $x \/ $y )) #clear echo \"Addition\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65695,"url":"http:\/\/bangla.sitestree.com\/?p=65695","url_meta":{"origin":65710,"position":5},"title":"Use of For Loops and Functions in Shell Programming #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"bash-3.2$ cat multiplication.sh #!\/bin\/bash # Example use of function\/method declaration in Shell Programming # Example use of for loop #a function that will multiply 1 to 10 with 5 multiplication() { x=5 for i in {1..10} do echo $i echo \"the multiplication result is:\" $(($i*$x)) done } echo \"Print 1\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65710"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65710\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65710"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}