• Breaking News

    we will continue soon thanks
    ...

    Linux basics

    TERMINAL CASE SYSTEM

    INTRODUCTION
    This a script of shell script aka terminal programming made by me this is a case system.
    In every computer language there is some common term this is one of this "CASE". In c++ we end case system normally as other languages but in the SHELL SCRIPT we end case system by flipping the word case to esac similar to if-if.
    This is the program for creating a file, removing a file, copying a file and renaming the file.

    THE SCRIPT

    clear
    echo " 1) Create a new file"
    echo " 2) Copy a file "
    echo " 3) Rename a file "
    echo " 4) Remove a file "

    echo "Enter your choice"
    read ch

    case $ch in
    1)clear
    echo "Enter the file name which you want to create : "
    read f1
    if [ -r $f1 ]
    then
    echo "Your file already exist !!!!!!!!!!!!"
    else
    cat > $f1
    echo "Your file is successfully created"
    fi
    ;;
    2)
    clear
    echo "Enter the source file name: "
    read f2
    echo "Enter the destination  file name : "
    read f3
    if [ -r $f2 ]
    then
    cp $f2 $f3
    echo "Your file successfully copied  "
    else
    echo "Your source file does not exist  !!!!!!!!!!!!!!!!"
    fi
    ;;
    3)
    clear
    echo "Enter the old file name:"
    read f4
    echo "Enter the new file name "
    read f5
    if [ -r $f4]
    then
    mv $f4 $f5
    echo "Your file is successfully renamed"
    else
    echo "Your old file does not exist "
    fi
    ;;
    4)
    clear
    echo "Enter the file name which you want to remove "
    read f6
    if [ -r $f6]
    then
    rm $f6
    echo "Your file is removed"
    else
    echo "Your file already exists "
    fi
    ;;
    *)
    echo "You entered the wrong choice"
    ;;
    esac

    Output

     ⇠⇠⇠ choosing option 1 to create a file


    ⬆⬆⬆ learnprot file is created

    CONCLUSION

    I conclude the topic. For further information about this topic comment below, please subscribe our blog through email by which you can get an email when I post a new post in this blog.follow us on Instagram twitter, facebook page. visit our pages in this blog for knowing me and my blog thank you  

    No comments