Thursday, July 31, 2014

Write a shell program to convert all lowercase letter in a file to uppercase letter

QUE: Write a shell program to convert all lowercase letter in a file to uppercase
letter.

ANS -

clear
        echo "Menu"
        echo "1. Lower Case to Upper Case"
        echo "2. Upper Case to lower Case"
        echo "3. Quit"
        echo "Enter ur Choice \c"
        read Choice
        case"$Choice"in
           1] echo "Enter File: \c"
              read f1
              if [ -f $f1 ]
          then
               echo "Converting Lower Case to Upper Case "
                 tr '[a-z]''[A-Z]' <$f1
                             
              else
                     echo "$f1 does not exist"
              fi
              ;;
          2] echo "Enter the File :\c"
             read f1
             if [ -f $f1 ]
             then      
               echo "Converting Upper case to Lower Case to "
             tr '[A-Z]''[a-z]' <$f1
                          
             else 
                  echo "$f1 file does not exist "
             fi
             ;;
         3|*) 
             echo "Exit......."
             exit;;
        esac

--------------------------------------------------------------------------------
output:

    $ cat >hello
    how r u ....
    how is the day....
    go.
    $ SH36
    Menu
    1. Lower to Upper
    2. Upper to lower
    3. Quit
    Enter ur Choice 1
    Enter the File :HELLO
    Converting Lower case to Upper Case to
    HOW R U ....
    HOW IS THE DAY.
    GO   
    $ SH36
    Menu
    1. Lower to Upper
    2. Upper to lower
    3. Quit
    Enter ur Choice 1
    Enter the File :HELLO
    Converting Lower Case to Upper Case
    XCO
    ASA
    GATE
    

No comments:

Post a Comment

COMMENT POLICY: We’re pleased to see your comment here. However, Please Keep in mind that all comments are moderated manually by humans according to our comment policy. Using Keywords and links to your blogs or websites in the name field area is forbidden. Let’s enjoy a personal and meaningful conversation. Do not break the rules of comment policy.