Skip to content

Instantly share code, notes, and snippets.

@purvesh0110
Created August 2, 2023 17:16
Show Gist options
  • Save purvesh0110/1e33a595dd46b25d419f18d1ee05f112 to your computer and use it in GitHub Desktop.
Save purvesh0110/1e33a595dd46b25d419f18d1ee05f112 to your computer and use it in GitHub Desktop.
#[task ---> 1 : Comments]
#This is the comment on the day 1 of 'TWS BashBlaze Challenge'
#[task ---> 2 : Echo ]
#this is echo command for showing the message in the double string
#(!/bin/bash) when used in scripts is used to instruct the operating system to use bash as a command interpreter.
#Each of the systems has its own shells which the system will use to execute its own system scripts.
#!/bin/bash
echo "hello this is the first day of TWS BashBlaze Challenge"
#[task ---> 3 : Variables]
#simple variable example
#!/bin/bash
variable = value
myname = PURVESH
#this is the echo command for showing value in variable i.e. myname
#!/bin/bash
echo $myname
#[task ---> 4 : Using Variables]
#!/bin/bash
# Declare variables
num1=5
num2=10
# Calculate sum of the two numbers
sum=$((num1 + num2))
# Print the sum
echo "The sum of $num1 and $num2 is: $sum"
#[task ---> 5 : Using Built-in Variables]
#!/bin/bash
# Get the current date and time
date=$(date)
# Get the current user
user=$(whoami)
# Get the current directory
dir=$(pwd)
# Print the information
echo "The current date and time is: $date"
echo "The current user is: $user"
echo "The current directory is: $dir"
#[task ---> 6 : Wildcards]
#!/bin/bash
# This script lists all the files with a specific extension in a directory.
# Get the directory and extension from the user.
echo "Enter the directory to search:"
read directory
echo "Enter the extension to search for:"
read extension
# List all the files with the specified extension in the directory.
find "$directory" -name "*.$extension" -print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment