Bash Scripting 101

Fahadul Islam
3 min readMay 7, 2021

How to write and Assign a Variable?

But Bash does not have a type system, it save string values.

N:B-with no spaces in between

How to take input from user?

How to command in BASH?

How to write Expression?

Expression command is expr.

N:B-space in (before + and After +).

Store this value in variable.

For Multiplication using backslash.

How to write Condition?

  • When don’t use space before expression error in below.

Example : Check if a is even

How to write multiple Condition?

How to use case (in C switch) statement?

How to use for loop?

Example : print 1 to 10 using loop

Example : Increment 3

Example : Decrement 3

How to use While loop?

Else If Example

How to write function?

$ * Means what is being sent as an argument.

Example : Parameter In Function

Example : Number Of Arguments

How return works in bash?

Way — 1

Way — 2(BETTER)

Example :

How to write Array?

Example : Different Way Initialize array.

Example: Number of elements of array

— — — — — — — — — — -The End — — — — — — — — — — — — — — — -

--

--