Basic Shell Scripting
First Script
Run Basic Tasks
Run Basic Administration Tasks
Defining Variables
Input=Output
Conditional/If else statements
Case Statements
For loop script
do-while
Getting Online help
#!/bin/bash
# Author: Shounak Khulape
# Date Created: 02/23/2024
# Description: This script will output "Hello World" on the screen
# Date Modified: 02/23/2024
echo
echo Hello World
echo
Basic Tasks Script
Create 2nd script to run basic tasks
pwd
ls
whoami
date
cal
touch a b c
Basic Administration Tasks
Create a script to run basic administration tasks
top
df -h
free -m
uptime
iostat
Defining Variables
Create script to run basic tasks
p=pwd
l=ls
w=whoami
d=date
c='cal 2018'
Input/output
Create script to take input from the user
read
echo
Conditional/If else statements
if-then statement
If then statement
If this happens = do this
Otherwise = do that
Case Statement Scripts
Case
If option a is selected = do this.
If option b is selected = do this.
If option c is selected = do this.
For Loop Scripts
For Loops
Keep running until specified number of variable
eg: variable = 10 the run the script 10 times
variable = green, blue, red (then run the script 3 times for each color.)
#!/bin/bash
# Author: Shounak Khulape
# Date Created: 02/23/2023
# Description: This script will run basic admin command
# Date Modified: 02/23/2024
echo
echo This script will run basic administrative commands
echo
top
echo
df -h
echo
uptime
echo
iostat
echo
echo End of Script
#!/bin/bash
# Author: Shounak Khulape
# Date Created: 02/23/2024
# Description: Run Basic linux tasks
# Date Modified: 02/23/2024
echo
echo This script will run a few basic tasks
echo
pwd
ls
whoami
date
cal
touch a b c
#!/bin/bash
# Author: Shounak Khulape
# Date Created: 02/23/2024
# Description: This script is to check if a file error exit
# Date Modified: 02/23/2024
echo
clear
if [ -e /home/oracle/error.txt ]
then
echo "File exist"
else
echo "File does not exist"
fi
#!/bin/bash
# Date Created: 02/23/2024
# Author: Shounak Khulape
# Description: This script is regarding if-then command
# Date Modified: 02/23/2024
count=100
if [ $count -eq 100 ]
then
echo Count is 100
else
echo Count is not 100
fi
#!/bin/bash
# Author: Shounak Khulape
# Date Created: 02/23/2023
# Description: This script is created to dispaly input/output command.
# Date Modified: 02/23/2024
a=`hostname`
echo
echo Hello, my server name is $a
echo
echo Hello, My Name is Shounak Khulape
echo
echo What is your name?
read namecont
echo
echo Hello $namecont
echo
#!/bin/bash
# Date Created: 02/26/2024
# Author: Shounak Khulape
# Description: This script check the response and then output
# Date Modified: 02/26/2024
echo
clear
echo
echo "What is your name?"
echo
read a
echo
echo Hello $a sir
echo
echo "Do you like working in IT? (y/n)"
read like
echo
if [ "$like" == y ]
then
echo You are cool
elif [ "$like" == n ]
then
echo "You Should try IT, it's a good field"
echo
fi
#!/bin/bash
# Author: Shounak Khulape
# Date Created: 02/23/2024
# Description: This script is screated for declaring varaiable command
# Date Modified: 02/23/2024
echo
# Define Variables
p=pwd
l=ls
wi=whoami
d=date
c="cal 2018"
echo Run variables tasks
echo
$p
$l
$wi
$d
$c
That's great if you have make till here you have covered Basic Shell Standards.
If you liked what you read, do follow and any feedback for further improvement will be highly appreciated!
Thank you and Happy Learning!👏