xxxxxxxxxx
there are diffrerent shells
bash is the most common one,
others are csh zsh etc..
xxxxxxxxxx
# Executable text file
# First line contains interpreter directive ("shebang" directive: #!interpreter [optional-arg])
# File contains list of commands
# Commands are interpreted at runtime (not compiled)
# Used to automate processes
# born shell directive
#!/bin/sh
# born again shell (bash) directive
#!/bin/bash
# python script directive
#!/usr/bin/env python3
# Example : Creating and executing a shell script
# Create shell script file
touch example.sh
# Appending directive to the script
echo '#! /bin/bash' >> example.sh
# Append other commands to the script
echo 'echo hello world' >> example.sh # Or you can do it by 'nano example.sh'
# Make sure the shell script is executable
ls -l example.sh # Check permission
chmod +x example.sh # Add executable permission if not there
# Execute shell script
./example.sh
xxxxxxxxxx
# Creating a shell script named "myshell1.sh"
#! /bin/bash
echo "Hi $1 $2"
#$1 is the first argument passed to the script
echo "$1 is your firstname"
#$2 is the second argument passed to the script
echo "$2 is your lastname"
# ..............................................
# Creating a shell script named "myshell2.sh"
#! /bin/bash
dircount=$(find $1 -type d|wc -l)
filecount=$(find $1 -type f|wc -l)
echo "There are $dircount directories in the directory $1"
echo "There are $filecount files in the directory $1"
# ..............................................
# Execute shell 1
./myshell1.sh FirstName LastName
# Execute shell 2
./myshell2.sh /tmp
xxxxxxxxxx
#A shell script is a computer program designed to be run by the Unix shell,a command-line interpreter.
#The various dialects of shell scripts are considered to be scripting languages.
#Typical operations performed by shell scripts include file manipulation,
#program execution,
#and printing text
insta: @hasu4167