MORE ON BASH SCRIPTS

From the previous text I introduced you some basic things in Bash Commands. From this text I’m going to go into much more deep in bash scripts, such as conditional statements and looping.

From the following examples it will show how to use conditional statements and looping with bash scripts.

  • Let’s see how to use IF statements,

if

This is the output of that file,

ifOUTPUT.png

  • SWITCH CASE

switchcase.png

switchcaseOUTPUT

  • FOR LOOP

for1

for1OUTPUT

for2

for2OUTPUT

  • WHILE LOOP

while

whileOUTPUT

  • UNTIL LOOP

until

untilOUTPUT

From the above examples you can get a clear idea about how to use conditional statements and loops in bash scripts. Also there are few operators are used with String manipulation. Few of them are showed below,

string

stringOUTPUT

If you want to find the length of a particular string, you can use this method.

length

lngthOUTPUT

Hope now you have an idea about, how to use conditional statements, loops., string manipulations with bash scripting. See you soon with another interesting topic. Thank You!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s