Skip to content

Commit

Permalink
initail commit
Browse files Browse the repository at this point in the history
  • Loading branch information
samirm00 committed Feb 29, 2024
1 parent 48cccb3 commit 1d9cbca
Showing 1 changed file with 65 additions and 27 deletions.
92 changes: 65 additions & 27 deletions 1-introduction-to-bash/1.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,76 @@
#!/bin/bash



# Author: Samir M.
# Date: 2024-02-29
# Modified Date: 2024-02-29
# Description: Introduction to Bash Scripting
# Modified: 2024-02-29
# Description: Comprehensive Bash Scripting Tutorial
# Usage: ./1.sh


# The shebang line is the first line of the script and tells the system what interpreter to use
# In this case, we are using the bash interpreter


# echo is a command that prints text to the terminal
echo "Hello, World!"

# printf is another command that prints text to the terminal
printf "%s\n" "Hello, World!"
# Introduction
echo "Welcome to the Comprehensive Bash Scripting Tutorial!"
echo "This script covers various Bash commands and scripting basics."

# Print the current shell
echo $SHELL

# Print the home directory
echo $HOME

# Print the current working directory
echo $PWD

# Print the current user
echo $USER

# Print the current date and time
echo $(date)
echo -e "\n1. System Information:"
echo " Current Shell: $SHELL"
echo " Home Directory: $HOME"
echo " Current Working Directory: $PWD"
echo " Current User: $USER"
echo " Current Date and Time: $(date)"
echo " System PATH: $PATH"
echo " Hostname: $(hostname)"

# File and Directory Operations
# e flag is used to enable interpretation of backslash escapes
echo -e "\n2. File and Directory Operations:"

# Create a directory
mkdir my_directory
echo " Created 'my_directory'"

# Change to the directory
cd my_directory
echo " Current Directory: $(pwd)"

# Create a new file
touch my_file.txt
echo " Created 'my_file.txt'"

# Display file content
echo -e "\n Content of 'my_file.txt':"
cat my_file.txt

# Delete the file
rm my_file.txt
echo " Deleted 'my_file.txt'"

# Delete the directory
cd ..
rm -r my_directory
echo " Deleted 'my_directory'"

# Process Information
echo -e "\n3. Process Information:"
# Display process information
echo " List of processes:"

# ps aux command is used to display all the running processes
ps aux

# User Input
echo -e "\n4. User Input:"

# Prompt for user input
read -p "Enter your name: " user_name

echo " Hello, $user_name! Welcome to Bash scripting."

# Make the script executable
# To calculate the permission, we use the following webiste: https://chmod-calculator.com/
# chmod 744 1.sh

# Execute the script
# ./1.sh



0 comments on commit 1d9cbca

Please sign in to comment.