Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Write a shell script to convert a file to lower case or upper case as specified by user.

Posted By: Reamonn Fischer     Category: Unix / Linux / Ubuntu     Views: 19654

Write a shell script to convert a file to lower case or upper case as specified by user.

Code for Write a shell script to convert a file to lower case or upper case as specified by user. in Unix / Linux / Ubuntu

clear
        echo "Menu "
        echo "1. Lower to Upper"
        echo "2. Upper to lower "
        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 ....
    NICE MEETING U.
    BYE
    $ SH36
    Menu
    1. Lower to Upper
    2. Upper to lower
    3. Quit
    Enter ur Choice 2
    Enter the File :HELLO
    Converting Upper case to Lower Case to
    how r u ....
    nice meeting u.
    bye    
    $ SH36
    Menu
    1. Lower to Upper
    2. Upper to lower
    3. Quit
    Enter ur Choice 1
    Enter the File :hell
    Converting Lower Case to Upper Case
    XCMSD
    CGF
    G
    DF DFD
    GHG  
  
Share: 



Reamonn Fischer
Reamonn Fischer author of Write a shell script to convert a file to lower case or upper case as specified by user. is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 

Other Interesting Articles in Unix / Linux / Ubuntu:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!