#Day8/90 of days of DevOps - Task: Shell Scripting Challenge.

#Day8/90 of days of DevOps - Task: Shell Scripting Challenge.

I'm excited to share my progress on #Day8/90 of days of DevOps - Task: Shell Scripting Challenge. Here are the tasks I completed

Task 1: Comments The first line is a shebang, which specifies the interpreter to use to run the script. The next line is a comment that explains what the script does.

Task 2: Echo The echo command is used to print a message to the terminal.

Task 3: Variables Two variables, MY_NAME and MY_AGE, are declared and assigned values.

Task 4: Using Variables Two variables, NUM1 and NUM2, are declared and assigned values. The SUM variable is calculated using arithmetic expansion, and the result is printed to the terminal.

Task 5: Using Built-in Variables Three built-in variables are used to display relevant information: PWD (current working directory), SHELL (current shell), and $# (number of command-line arguments).

Task 6: Wildcards The ls command is used with a wildcard pattern *.txt to list all files with a .txt extension in the current directory.

The script ends with a final message indicating that it has completed successfully.

#!/bin/bash

# Task 1: Comments
# This script demonstrates various bash concepts, including comments, echo, variables, and wildcards.

# Task 2: Echo
# Print a message to the terminal
echo "Welcome to my bash script!"

# Task 3: Variables
# Declare variables and assign values to them
MY_NAME="John Doe"
MY_AGE=30

# Task 4: Using Variables
# Take two variables as input and print their sum
NUM1=10
NUM2=20
SUM=$((NUM1 + NUM2))
echo "The sum of $NUM1 and $NUM2 is $SUM"

# Task 5: Using Built-in Variables
# Utilize built-in variables to display relevant information
echo "Current working directory: $PWD"
echo "Current shell: $SHELL"
echo "Number of command-line arguments: $#"

# Task 6: Wildcards
# List all files with a .txt extension in the current directory
echo "Files with .txt extension:"
ls *.txt

# End of script
echo "Script completed successfully!"        

To view or add a comment, sign in

More articles by Ram Ji Gupta

Explore content categories