{"id":65716,"date":"2021-07-12T04:10:04","date_gmt":"2021-07-12T08:10:04","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/while-loop-example-in-shell-programming-display-a-chart-linux-unix-shell-programming-001\/"},"modified":"2021-07-12T04:10:04","modified_gmt":"2021-07-12T08:10:04","slug":"while-loop-example-in-shell-programming-display-a-chart-linux-unix-shell-programming-001","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=65716","title":{"rendered":"While Loop Example in Shell Programming. Display a Chart #Linux\/Unix: Shell Programming &#8211; 001"},"content":{"rendered":"<p>Example Output<\/p>\n<p>bash-3.2$ .\/while-loop-example.sh<br \/>\nEnter your Number<br \/>\n10<br \/>\n10 * 1 = 10<br \/>\n10 * 2 = 20<br \/>\n10 * 3 = 30<br \/>\n10 * 4 = 40<br \/>\n10 * 5 = 50<br \/>\n10 * 6 = 60<br \/>\n10 * 7 = 70<br \/>\n10 * 8 = 80<br \/>\n10 * 9 = 90<br \/>\n10 * 10 = 100<\/p>\n<hr \/>\n<p>The Code<\/p>\n<p>&nbsp;<\/p>\n<p>#!\/bin\/ksh<\/p>\n<p>#example : how to use while loop in shell programming<\/p>\n<p>multiplication()<br \/>\n{<\/p>\n<p>#clear<br \/>\ni=1<br \/>\nwhile (( i &lt;= 10 ))<br \/>\ndo<br \/>\necho &#8220;$Y * $i = `expr $Y * $i`&#8221;<br \/>\n(( i = i + 1 ))<br \/>\ndone<\/p>\n<p>}<\/p>\n<p>echo &#8220;Enter your Number&#8221;<br \/>\nread X<\/p>\n<p>case &#8220;$X&#8221; in<\/p>\n<p>1)<br \/>\nY=1<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>2)<\/p>\n<p>Y=2<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>3)<\/p>\n<p>Y=3<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>4)<\/p>\n<p>Y=4<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>5)<\/p>\n<p>Y=5<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>6)<\/p>\n<p>Y=6<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>7)<\/p>\n<p>Y=7<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>8)<\/p>\n<p>Y=8<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>9)<\/p>\n<p>Y=9<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>10)<\/p>\n<p>Y=10<br \/>\nmultiplication<br \/>\n;;<\/p>\n<p>esac<br \/>\nexit From: http:\/\/sitestree.com\/?p=12197<br \/> Categories:Linux\/Unix: Shell Programming &#8211; 001<br \/>Tags:<br \/> Post Data:2018-04-16 19:31:36<\/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>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 * 9 = 90 10 * &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=65716\">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_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-65716","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":65695,"url":"http:\/\/bangla.sitestree.com\/?p=65695","url_meta":{"origin":65716,"position":0},"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":[]},{"id":14152,"url":"http:\/\/bangla.sitestree.com\/?p=14152","url_meta":{"origin":65716,"position":1},"title":"\u09b6\u09c7\u09b2 \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae\u09bf\u0982 \u098f for \u09b2\u09c1\u09aa \u098f\u09ac\u0982 \u09ab\u09be\u0982\u09b6\u09a8 \u098f\u09b0 \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0\u0964 Use of For Loop and Function in Shell Programming","author":"Sayed","date":"April 15, 2018","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;\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":65716,"position":2},"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":14165,"url":"http:\/\/bangla.sitestree.com\/?p=14165","url_meta":{"origin":65716,"position":3},"title":"For \u09b2\u09c1\u09aa \u098f\u09b0 \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0","author":"Sayed","date":"April 16, 2018","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;\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":65689,"url":"http:\/\/bangla.sitestree.com\/?p=65689","url_meta":{"origin":65716,"position":4},"title":"Arithmetic Operations using two variables #Linux\/Unix: Shell Programming &#8211; 001","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"#!\/bin\/sh #will do addition, subtraction, multiplication, and division of two variables X=12 Y=5 #print the values of the variables echo \"X value is: \"$X echo \"Y value is: \"$Y #addition echo \"X + Y\" = `expr $X + $Y` #subtraction echo \"Y - X\" = `expr $Y - $X` #multiplication\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":14144,"url":"http:\/\/bangla.sitestree.com\/?p=14144","url_meta":{"origin":65716,"position":5},"title":"\u0997\u09be\u09a3\u09bf\u09a4\u09bf\u0995 \u0985\u09aa\u09be\u09b0\u09c7\u09b6\u09a8 &#8211; \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0\u0995\u09be\u09b0\u09c0 \u09a5\u09c7\u0995\u09c7 \u09a6\u09c1\u099f\u09bf \u09ae\u09be\u09a8 \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0 \u0995\u09b0\u09c7 : Arithmetic operations using two values from the user","author":"Sayed","date":"April 15, 2018","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;\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":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65716","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=65716"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65716\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65716"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}