UNIX / Linux | Loops in Shell Programming | Exp - 4

unix-linux-shell-programing

Shell Programming in UNIX/Linux

BASH (which stands for Bourne Again Shell) is a scripting language utilized by most Linux and UNIX-based operating systems.
You can run BASH commands within a terminal window one after the other or you can add the commands to a text file to produce a shell script.
Scripting languages such as BASH have similar programming constructs as other languages. For instance, you can use import parameters to get input from the keyboard and store them as variables. You can then get the script to perform a certain action based on the value of the input parameters
The BASH way of using "for" loops is somewhat different to the way most other programming and scripting languages handle "for" loops. Let's break the script down.
In a BASH "for" loop all, the statements between do and done are performed once for every item in the list.
Syntax:
for i in 1, 2, 3, ... , N
do
         expression
done
or
for i in {1 .. N}
do
         expression
done

or

for i in {1 .. N .. 1}
do
         expression
done

or

for (( i=0 ; i<n ; i++ ))
do
         expression
done

For more info visit Lifewire


Problem Statement

Create Multiplication Table for any number.


.

No comments:

Powered by Blogger.