Day 8 :- 🖥️ Exploring Bash Scripting Fundamentals

Day 8 :- 🖥️ Exploring Bash Scripting Fundamentals

Day 8 :- TASK

• Task 1: Comments

In bash scripts, comments are used to add explanatory notes or disable certain lines of code. Your task is to create a bash script with comments explaining what the script does.

#!/bin/bash
<<readme
info: this script will give you date and time
readme

#this script will print date and time

#print the current time and date
echo "Date and time is $(date)"

#print welcome message
echo "Welcome to scripting challenge"

#end of script

Echo

The echo command is used to display messages on the terminal. Your task is to create a bash script that uses echo to print a message of your choice.

#!/bin/bash
<<readme
info : this file will print use of echo
readme


echo "Hello everyone this is my day08 of devops jounrey stay tuned"

Variables

Variables in bash are used to store data and can be referenced by their name. Your task is to create a bash script that declares variables and assigns values to them.

#!/bin/bash


name="Anand Raval"
challenge="90DaysOfDevops"

Using Variables

Now that you have declared variables, let's use them to perform a simple task. Create a bash script that takes two variables (numbers) as input and prints their sum using those variables.

#!/bin/bash


read -p "Enter value of A:" a
read -p "Enter value of B:" b

sum=$((a+b))

echo "$a+$b=$sum"

Using Built-in Variables

Bash provides several built-in variables that hold useful information. Your task is to create a bash script that utilizes at least three different built-in variables to display relevant information.

#!/bin/bash

echo "Current loged in user:$USER"
echo "Home directory:$HOME"
echo "Current shell:$SHELL"

Wildcards

Wildcards are special characters used to perform pattern matching when working with files. Your task is to create a bash script that utilizes wildcards to list all the files with a specific extension in a directory

#!/bin/bash


echo "printing all list of directories"

ls *.txt

Thank you for reading!

© 2024 Anand Raval. All rights reserved.