09 Shell Scripting

Scripts is a command line program

 

scripts

 

 

script.sh

#!/bin/bash

echo “Script is fun!”

 

$   chmod 755 script.sh

$  ./script.sh

Script is fun!

$

shebang

 

Variables

Variables

 

Variable Names

Variable Names

 

 

Making Decision The if statement

 

if [condition-is-true]

then

command 1

command 2

command N

fi

 

if/else

if [condition-is-true]

then

command N

else

command N

fi

 

if/elif/else

if [condition-is-true]

then

command N

elif [condition-is-true]

then

command N

else

command N

fi

 

For loop

for VARIABLE_NAME in ITEM_1 ITEM_N

do

command 1

command 2

command N

done

 

Positional Parameters

Positional Parameters