Shell script to print table of a given number Last Updated : 31 Jul, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will explore the process of creating a simple yet powerful shell script that takes user input and generates number tables. Number tables are a common mathematical concept used to display the multiples of a given number up to a specified limit. We will illustrate this process with examples for better understanding. Example:Input: 5 Output: 5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25 5 * 6 = 30 5 * 7 = 35 5 * 8 = 40 5 * 9 = 45 5 * 10 = 50 Explanation: Here the multiple of 5 are printed. Input: 8 Output: 8 * 1 = 8 8 * 2 = 16 8 * 3 = 24 8 * 4 = 32 8 * 5 = 40 8 * 6 = 48 8 * 7 = 56 8 * 8 = 64 8 * 9 = 72 8 * 10 = 80 Explanation: Here the multiple of 8 are printed. Here our task is to write a script to take the input integer variable and print its multiples till 10 or simply we can say that the below script prints the table of the input value till its 10th multiple. At the same time, the loop is used to iterate the loop till the 10th multiple. #!/bin/bash # Input from user echo "Enter the number -" read n # initializing i with 1 i=1 # Looping i, i should be less than # or equal to 10 while [ $i -le 10 ] do res=`expr $i \* $n` # printing on console echo "$n * $i = $res" # incrementing i by one ((++i)) # end of while loop done Output:Bash Script outputThe following screenshot of the test case of the code is executed, it accepts the input data from the user. The input will be in integer format and then print the desired table. Comment More infoAdvertise with us Next Article Shell script to print table of a given number C codeutin Follow Improve Article Tags : Linux-Unix Shell Script Similar Reads Shell Script to print odd and even numbers In this article, we will discuss how to print even and odd numbers. We will take a number as input and print all even and odd numbers from 1 to the number. Input : Enter the Number - 10 Output : Even Numbers - 2, 4, 6, 8, 10 & Odd Numbers - 1, 3, 5, 7, 9 Input : Enter the Number - 5 Output : Eve 2 min read Bash shell script to find sum of digits Given a number Num, find the sum of digits of the number.Examples: Input : 444 Output : sum of digits of 444 is : 12 Input : 34 Output : sum of digits of 34 is : 7 Approach: 1. Divide the number into single digits 2. Find the sum of digits . Bash # !/bin/bash # Program to find sum # of digits # Stat 1 min read Shell Script to Display the Digits which are in Odd Position Here given a list of numbers, our task is to find the odd position from the given number. Example: Input: 123456 Output: 135 Explanation: 1, 2, 3 are at odd position. Input: 34567 Output: 357 Explanation: 3, 5, 7 are at odd position. We will have to input a number from the user for a dynamic script. 2 min read Looping Statements | Shell Script Looping Statements in Shell Scripting: There are total 3 looping statements that can be used in bash programming Table of Content `while` statement in Shell Script in Linux`for` statement in Shell Script in Linux`until` statement in Shell Script in LinuxExamples of Looping StatementsTo alter the fl 10 min read Write a Bash Script to Print a Particular Line From a File One useful tool for automating operations in Unix-based systems is bash scripting. The need to print a certain line from a file is one such requirement. This post will walk you through writing a basic Bash script that accomplishes that. The fundamentals of utilizing conditional statements, showing t 3 min read Like