bash script linux code example

Example 1: bash scripting

#!/bin/sh

# Author : Zara Ali
# Copyright (c) Tutorialspoint.com
# Script follows here:

echo "What is your role"
read ROLE
echo "My Role : $ROLE"

Example 2: bash "=~" example

$ [[ 45 =~ [0-9]+ ]] && echo "45 contains digits"
45 contains digits

$ [[ "hello" =~ [0-9]+ ]] && echo "hello doesnt contains digits"
$ [[ "hello" =~ [a-z]+ ]] && echo "hello contains alphabets"
hello contains alphabets

Example 3: shell script linux

#!/bin/bash
echo "Hello World!"

Example 4: linux shell script

#!/bin/bash
echo "Hello World"