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

#!/bin/bash
echo "el nombre del programa es $0"
#el echo muestra por pantalla el mensaje escrito entre comillas.
echo "El número total de parámetros es $#"
echo "Todos los parámetros recibidos son $*"
echo "El primer parámetro recibido es $1"
shift
#El comando shift desplaza los parámetros, de modo que lo que es $2 se convierte en $1, $3 pasaría a ser $2 y así sucesivamente, menos $0 que no es alterado
echo "El segundo parámetro recibido es $1"
shift
echo "El tercer parámetro recibido es $1"
echo "El cuarto parámetro recibido es $2"
#el programa muestra por pantalla ciertos parametros establecidos, pero el shift desplaza los parametros haciendo que cambien de lugar.

Execute Bash Shell Online

# Hello World Program in Bash Shell

# Basic if statement

#!/bin/bash
echo what is your access name ? 

read name

if [ $name ==  'bassem' ] 

then
echo you can enter
else 
echo access denied


fi
date

test

# Hello World Program in Bash Shell

echo "Haaaaaaaaaaelloaa Worlaaad!a" | sed 's/aa*/a/g' 

echo "Haaaaaelloaa Worlaaad!a" | tr -s a

echo "Haaaaelloaa Worlaaad!a" | tr -dc a | wc -c 
echo "Haaaaelloaa Worlaaad!a" | tr -dc o | wc -c

echo "we are as apple odd fan ls grep" | grep ls

Execute Bash Shell Online

# Hello World Program in Bash Shell

declare nos[5]=(4 -1 2 66 10)
# Prints the number befor sorting

echo "Original Numbers in array:"
for (( i = 0; i <= 4; i++ ))
    do
      echo ${nos[$i]}
    done

test

# Hello World Program in Bash Shell

echo "Hello World!"

ocas

# Hello World Program in Bash Shell

echo "Hello World!"
ls
ls -lrt
pwd

loop

 clear
AutoNumber()
{
            local rollno=0     
            f=0
            for j in `cat student.txt`
            do
                        rollno=$(echo "$j" | cut -d "," -f 1)
                        f=1
            done
            if [ $f = 1 ]
            then
                        rollno=`expr $sno + 1`
            else
                       rollno=1
            fi
            echo $rollno
}

 Insert()
{
            clear
           
            rollno=$1           
            echo "Enter Student RollNo: $rollno"
           
            echo "Enter Student First Name: \c"
            read sfnm

            echo "Enter Student last Name: \c"
            read slnm
           
            echo "Enter Marks of Experiments1 : \c"
            read em1

            echo "Enter Marks of Experiments2 : \c"
            read em2

            echo "Enter Marks of Experiments3 : \c"
            read em3

            echo "Enter Marks of Experiments4 : \c"
            read em4

            echo "Enter Marks of Experiments5 : \c"
            read em5  

            echo "Enter Marks of Experiments6 : \c"
            read em6

            echo "Enter Marks of Experiments7 : \c"
            read em7

            echo "Enter Marks of Experiments8 : \c"
            read em8
                       
            echo "$sno,$sfnm,$slnm,$em1,$em2,$em3,$em4,$em5,$em6,$em7,$em8,true" >> Student.txt

            echo "                 Insert Sucessfully                           "

}

 Display()
{
            clear
            echo "__________________________________________________"                       
            echo "                   Students’ Information System "
            echo "__________________________________________________"                       
            echo "__________________________________________________"                       
            echo "#ROLLNO \t SFNAME \t SLNAME \t\t\t\tEM1 \tEM2 \tEM3 \tEM4 \tEM5 \tEM6 \tEM7 \tEM8"    
        
            for j in `cat Student.txt`
            do
                        rollno=$(echo "$j" | cut -d "," -f 1)
                        sfnm=$(echo "$j" | cut -d "," -f 2)
                        slnm=$(echo "$j" | cut -d "," -f 3)
                        em1=$(echo "$j" | cut -d "," -f 4)
                        em2=$(echo "$j" | cut -d "," -f 5)
                       
                        em3=$(echo "$j" | cut -d "," -f 6)
                        em4=$(echo "$j" | cut -d "," -f 7)
                        em5=$(echo "$j" | cut -d "," -f 8)
                        em6=$(echo "$j" | cut -d "," -f 9)
                        em7=$(echo "$j" | cut -d "," -f 10)
                        em8=$(echo "$j" | cut -d "," -f 11)
                        tfval=$(echo "$j" | cut -d "," -f 12)
                        if [ $tfval = "true" ]
                        then
                                  echo "___________________________________________"
                                  echo "$rollno \t $sfnm \t $slnm \t\t $em1 \t\t $em2 \t $em3 \t $em4 \t $em5 \t $em6 \t $em7 \t $em8"
                        fi
            done   
            echo "__________________________________________________"                       
}

 Search()
{
            clear

            echo "Enter Student ROLLNO: \c"
            read no

            echo "__________________________________________________"                       
            echo "                 Students’ Information System                       "
            echo "__________________________________________________"                       
            flag=0
            for j in `cat Student.txt`
            do
                        rollno=$(echo "$j" | cut -d "," -f 1)
                        sfnm=$(echo "$j" | cut -d "," -f 2)
                        slnm=$(echo "$j" | cut -d "," -f 3)
                        em1=$(echo "$j" | cut -d "," -f 4)
                        em2=$(echo "$j" | cut -d "," -f 5)
                        em3=$(echo "$j" | cut -d "," -f 6)
                        em4=$(echo "$j" | cut -d "," -f 7)
                        em5=$(echo "$j" | cut -d "," -f 8)
                        em6=$(echo "$j" | cut -d "," -f 9)
                        em7=$(echo "$j" | cut -d "," -f 10)
                        em8=$(echo "$j" | cut -d "," -f 11)
                        tfval=$(echo "$j" | cut -d "," -f 12)
                                               
                        if [ $no -eq $rollno ] && [ $tfval = "true" ]
                        then
                                    flag=1
                                 echo "________________________________________"                        
                                    echo "  ROLLNo : $rollno                      SFName : $sfnm            SlName : $slnm"  
                                    echo "________________________________________"                        
                                    echo "  EM1                    :                      $em1   "
                                    echo "  EM2                    :                      $em2   "
                                    echo "  EM3                    :                      $em3   "
                                    echo "  EM4                    :                      $em4   "
                                    echo "  EM5                    :                      $em5   "
                                    echo "  EM6                    :                      $em6   "
                                    echo "  EM7                    :                      $em7   "
                                    echo "  EM8                    :                      $em8   "

                                    echo "________________________________________"                        
                                              
                        fi
            done
            if [ $flag = 0 ]
            then
                 echo "               No Record Found              "
            fi
            echo "__________________________________________________"          

 }
Delete()
{
            clear
            f=0
            echo "Enter Student ROLLNO: \c"
            read no

            for j in `cat Student.txt`
            do
                        rollno=$(echo "$j" | cut -d "," -f 1)
                        sfnm=$(echo "$j" | cut -d "," -f 2)
                        slnm=$(echo "$j" | cut -d "," -f 3)
                        em1=$(echo "$j" | cut -d "," -f 4)
                        em2=$(echo "$j" | cut -d "," -f 5)
                        em3=$(echo "$j" | cut -d "," -f 6)
                        em4=$(echo "$j" | cut -d "," -f 7)
                        em5=$(echo "$j" | cut -d "," -f 8)
                        em6=$(echo "$j" | cut -d "," -f 9)
                        em7=$(echo "$j" | cut -d "," -f 10)
                        em8=$(echo "$j" | cut -d "," -f 11)

                        if [ $no -eq $rollno ]
                        then
                                    f=1                              
                                    line=$(echo "$rollno,$sfnm,$slnm,$eadd,$em1,$em2,$em3,$em4,$em5,$em6,$em7,$em8,false")
                                    fnm=`cat Student.txt`
                                    d=$(echo "$fnm" | sed s/$j/$line/g )
                                    echo $d > Student.txt          
                                    echo "                 Delete Successfully                           "
                        fi
            done
            if [ f = 0 ]
            then
                          echo "               No Record Found              "
            fi
}                
 

Update()
{
            clear

            echo "Enter Student ROLLNO: \c"
            read no


                       
            for j in `cat Student.txt`
            do
                                                rollno=$(echo "$j" | cut -d "," -f 1)
                        sfnm=$(echo "$j" | cut -d "," -f 2)
                        slnm=$(echo "$j" | cut -d "," -f 3)
                        em1=$(echo "$j" | cut -d "," -f 4)
                        em2=$(echo "$j" | cut -d "," -f 5)
                        em3=$(echo "$j" | cut -d "," -f 6)
                        em4=$(echo "$j" | cut -d "," -f 7)
                        em5=$(echo "$j" | cut -d "," -f 8)
                        em6=$(echo "$j" | cut -d "," -f 9)
                        em7=$(echo "$j" | cut -d "," -f 10)
                        em8=$(echo "$j" | cut -d "," -f 11)

                       
                        if [ $no -eq $rollno ]
                        then
                                    echo "______________Enter New Record______________"
                                    echo "Enter Student RollNo: $eno"
           
                                    echo "Enter Student first Name: \c"
                                    read sfnm

                                    echo "Enter Student Name: \c"
                                    read slnm
           
                                    echo "Enter Marks of Experiments1 : \c"
                                    read em1
           
                                    echo "Enter Marks of Experiments2: \c"
                                    read em2
           
                                    echo "Enter Marks of Experiments3 : \c"
                                    read em3

                                    echo "Enter Marks of Experiments4 : \c"
                                    read em4
                             
                                    echo "Enter Marks of Experiments5 : \c"
                                    read em5

                                    echo "Enter Marks of Experiments6 : \c"
                                    read em6

                                    echo "Enter Marks of Experiments7 : \c"
                                    read em7

                                    echo "Enter Marks of Experiments8 : \c"
                                    read em8


           
                                    line=$(echo "$rollno,$sfnm,$slnm,$em1,$em2,$em3,$em4,$em5,$em6,$em7,$em8,true")

                                    #line=$(echo "$rollno,$sfnm,$m1,$m2,$m3,$total,$per,true")
                                    fnm=`cat Student.txt`
                                    d=$(echo "$fnm" | sed s/$j/$line/g )
                                    echo $d > Student.txt          
                                   
                                    echo "                 Update Sucessfully                           "

                        fi
            done
 }




   while [ true ]
do
echo " _______________________________"
echo " 1. Insert  "
echo " 2. Delete  "
echo " 3. Update  "
echo " 4. Display "
echo " 5. Search  "
echo " 6. Exit    "
echo " _______________________________" 
echo "Enter Choice: \c"
read ch

case $ch in

            1)
               nxtSrNo=$(AutoNumber)
               Insert $nxtSrNo
               ;;
            2) Delete ;;
            3) Update ;;
            4) Display ;;
            5) Search ;;
            6) break;;
            *) echo " Wrong Choice "
esac
done

Work Around

#!/bin/sh

echo "File Name: $0"
echo "First Parameter : $1"
echo "Second Parameter : $2"
echo "Quoted Values: $@"
echo "Quoted Values: $*"
echo "Total Number of Parameters : $#"

jewel

# Hello World Program in Bas


h Shell

echo "Hello World!"

test

 

cat > testscript.txt

Advertisements
Loading...

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