Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Bash Shell Online

# Hello World Program in Bash Shell

TO_ADDRESS="[email protected]"
FROM_ADDRESS="[email protected]"
SUBJECT="Test email"
BODY="THIS IS A LINUX TEST EMAIL."

echo ${BODY}| mail -s ${SUBJECT} ${TO_ADDRESS} -- -r ${FROM_ADDRESS}

fdsafas

cat <<EOF |
8 192.27.69.191
2 82.202.69.253
EOF
xargs -n2 sh -c '
    # format the output as "$2 ($1): "
    printf "%s (%s): " "$2" "$1"
    # repeat the character `#` $1 times
    seq "$1" | xargs printf "#%.0s"
    # lastly a newline
    printf "\n"
' --

#xargs -n2 sh -c 'printf "%s (%s): %s\n" "$2" "$1" $(printf "#%.0s" $(seq $1))' --
#xargs -n2 sh -c 'echo "$2 ($1): $(printf "#%.0s" $(seq $1))"' --

Circle

echo "Enter the radius:" 
read r 
pi=`expr 22 / 7` 
area=`expr $pi \* $r \* $r` 
echo "Area of circle=$area" 

Regex sparsebundle

content="120614_achaibi.sparsebundle"
regex="\_(.*)"

[[ $content =~ $regex ]]
echo $(date +%F)_${BASH_REMATCH[1]}

Write a script program to use the SWITCH Command

#!/bin/tcsh
echo "Please enter a word: "
read input
#set input = $<
case $input in test)
 echo "This is a test"
 ;;
hello)
 echo "Hello world!"
 ;;
exits)
 echo "Thank you for playing"
 ;;
esac

Execute Bash Shell Online

#include<stdio.h>
#include<string.h>
void main(){
    char name[20];
    int phone_no[20], opt;
    printf("***PHONE BOOK***");
    printf("\n Select an option: \n 1 add a contact \n 2 edit a contact \n 3, delete a contact \n 4. view contacts 5. exit");
    scanf("%d", &opt);
    printf("end");
    
}

lint

#!/bin/bash
dir="./log.tar"
if [!-d$dir]; then
echo"DIRECTORY $dir DOES NOT EXIST"
echo"DIRECTORY EXIST CREATED FIVES DAY AGO"
rmdir ./log.tar
echo"DELETING EXISTING DIRECTORY"
echo"CREATING NEW DIRECTORY $dir"
mkdir log.tar
echo"$dir WAS SUCCESFULLY CREATED"
echo"CHECKING IF THE DIRECTORY $dir IS EMPTY"
if ["$(ls-A $)"]; then
echo"$dir IS NOT EMPTY"
echo"CREATING AN ARCHIVE $dir"
tar-cfv ./log.tar ~/backuptar.bz2
echo"$dir WAS SUCCESFULLY COMPRESSED"
exit 1; fi
else 
echo "exiting script"
fi

wms1

# Hello World Program in Bash Shell

path="atish_tasking.bat wq wm -tINFO "-Dlogging.config=logback.xml" "--spring.config.location=connector-config.yaml" "

arrays=', ' read -r -a array <<< "$path"
PARAMS=;
LOGLEVEL='ERROR'
SPRINGPARAMS=' '
LOGCONFIG=''
BATFILE=${array[0]}
echo ${BATFILE}
for index in "${!array[@]}"
do
    #echo "$index ${array[index]}"
    log="${array[index+1]:0:2}"
    #echo "$log"
    if [[ "$log" == "-t" ]]; then
      #length= expr length "${array[index+1]}"
        length=${#array[index+1]}
        level="${array[index+1]:2:length}"
        level="${level^^}"
        if [[ "$level" == "DEBUG" ]]; then
            LOGLEVEL="DEBUG"
            echo "$LOGLEVEL"
        elif [[ "$level" == "WARN" ]]; then
            LOGLEVEL="WARN"
            echo "$LOGLEVEL"
        elif [[ "$level" == "INFO" ]]; then
            LOGLEVEL="INFO"
            echo "$LOGLEVEL"
        elif [[ "$level" == "TRACE" ]]; then
            LOGLEVEL="TRACE"
            echo "$LOGLEVEL"
        else
            LOGLEVEL="ERROR"
            echo "$LOGLEVEL"
        fi
        
    
    elif [[ "$log" == "-D" ]]; then
            length=${#array[index+1]}
            if [[ "${array[index+1]:0:16}" == "-Dlogging.config" ]]; then
                LOGCONFIG="${array[index+1]:0:length}"
                echo "$LOGCONFIG"
            fi
    elif [[ "$log" == "--" ]]; then
        length=${#array[index+1]}
         if [[ "${array[index+1]:0:8}" == "--spring" ]]; then
        SPRINGPARAMS="${array[index+1]:0:length}"
        echo "$SPRINGPARAMS"
        fi
    else
        
        length=${#array[index+1]}
        param="${array[index+1]:0:length}"
        PARAMS=$PARAMS$tab$param
        tab=' ';
    fi
done
 echo "$PARAMS"
 
 echo java -cp wsm-0.0.16.jar $LOGCONFIG -Dlogging.level.root=$LOGLEVEL org.springframework.boot.loader.PropertiesLauncher $PARAMS $SPRINGPARAMS

Execute Bash Shell Online

# Hello World Program in Bash Shell

echo "Hello World!"

clear

compare_file

# Hello World Program in Bash Shell

echo "Hello World!" 

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.