how to convert user input to uppercase | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

how to convert user input to uppercase

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-15-2010
milink milink is offline
Registered User
 
Join Date: Sep 2010
Last Activity: 26 October 2012, 7:43 AM EDT
Posts: 78
Thanks: 9
Thanked 1 Time in 1 Post
how to convert user input to uppercase

Hi,

how to convert user input (lowercase) to uppercase in the dos batch file ?


Code:
echo. 
SET /p user1=Enter username:
SET user2=%user1%V
echo.
echo %user1%
echo.
echo %user2%
echo.

With Regards
Sponsored Links
    #2  
Old 12-15-2010
rsivasan rsivasan is offline
Registered User
 
Join Date: Nov 2009
Last Activity: 20 March 2013, 6:25 AM EDT
Posts: 45
Thanks: 4
Thanked 0 Times in 0 Posts
echo "siva"|tr 'a-z' 'A-Z'
Sponsored Links
    #3  
Old 12-15-2010
milink milink is offline
Registered User
 
Join Date: Sep 2010
Last Activity: 26 October 2012, 7:43 AM EDT
Posts: 78
Thanks: 9
Thanked 1 Time in 1 Post
Hi,

Thanks that works, further

I want to assign that value to some variable say U1 and want to define new user value by appending 'V' to that value.

For example.
user entered value is db then after using your provided command it shows DB, so

U1=DB (How to assign the "uppercase" output value to U1?)

U2 shoud be as 'DBV' (how to generate the new value as ''DBV" and assign to U2 ?)

With Regards
    #4  
Old 12-15-2010
R0H0N's Avatar
R0H0N R0H0N is offline
Registered User
 
Join Date: Nov 2010
Last Activity: 6 May 2012, 1:49 PM EDT
Location: which ((who am i))
Posts: 302
Thanks: 6
Thanked 47 Times in 46 Posts

Code:
U1=`echo siva | tr '[a-z]' '[A-Z]'`
U2="${U1}V"

Sponsored Links
    #5  
Old 12-15-2010
milink milink is offline
Registered User
 
Join Date: Sep 2010
Last Activity: 26 October 2012, 7:43 AM EDT
Posts: 78
Thanks: 9
Thanked 1 Time in 1 Post
Hi,


U1=`echo siva | tr '[a-z]' '[A-Z]'`
U2="${U1}V"
Assigning value to variable (U1, U2) as shown above is not working in the batch script. How to write the same in batch script ?

With Regards
Sponsored Links
    #6  
Old 12-15-2010
R0H0N's Avatar
R0H0N R0H0N is offline
Registered User
 
Join Date: Nov 2010
Last Activity: 6 May 2012, 1:49 PM EDT
Location: which ((who am i))
Posts: 302
Thanks: 6
Thanked 47 Times in 46 Posts
This link may help you.
Sponsored Links
    #7  
Old 12-15-2010
milink milink is offline
Registered User
 
Join Date: Sep 2010
Last Activity: 26 October 2012, 7:43 AM EDT
Posts: 78
Thanks: 9
Thanked 1 Time in 1 Post
Hi,

" tr " command is not working in the batch script.


With Regards
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Convert the first letter of each line to uppercase ramky79 Shell Programming and Scripting 4 11-04-2010 02:53 PM
Convert string to uppercase wtolentino UNIX for Dummies Questions & Answers 1 11-13-2009 09:00 AM
sed help to convert from lowercase to uppercase and vice versa! salman4u Shell Programming and Scripting 6 03-21-2009 08:38 AM
How do you take what a user types in and convert it into a variable to be used signebedi Shell Programming and Scripting 1 06-12-2008 03:27 PM
How convert lowercase or uppercase Alex20 Shell Programming and Scripting 5 03-07-2005 06:07 AM



All times are GMT -4. The time now is 07:43 PM.