make uppercase


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers make uppercase
# 1  
Old 05-28-2007
make uppercase

If in a script I am taking an input (R201) for example and assigning it to a variable, how would I change the R to uppercase if it was keyed in as r201? I can't seem to get it to work with toupper
# 2  
Old 05-28-2007
Using typeset

Krikm,
You can use the typeset options.The following script is an attempt to solve the problem.

Code:
#!/bin/ksh
typeset -u input
echo "Please Enter the input value:\c"
read input
echo "You Entered : $input"

Thanks
Nagarajan Ganesan.
# 3  
Old 05-28-2007
Thanks

That works like a charm...I had never seen that before.
# 4  
Old 05-28-2007
Code:
# var=r201
# new=$(echo $var|awk -F "" 'BEGIN{OFS=""}{ $1=toupper($1)}1')
# echo $new
R201

# 5  
Old 05-29-2007
the other option would be to use the tr command

Code:
$ echo r201 | tr '[a-z]' '[A-Z]'
R201

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Uppercase variable

Hello, This is not a problem specific question. While surfing on google to find a solution for the latest error messages I have received from command line, I found some suggestions regarding usage of linux commands: Could it be a problem specific comment or in most cases, `` causes issue?... (6 Replies)
Discussion started by: baris35
6 Replies

2. Shell Programming and Scripting

Cannot find correct syntax to make file name uppercase letters

I have a file name : var=UsrAccChgRpt I want to make them upper case. Tried: $var | tr Error: tr: Invalid combination of options and Strings. Usage: tr | -ds | -s | -ds | -s ] String1 String2 tr { -d | -s | -d | -s } String1 Could you please help. I am using AIX... (2 Replies)
Discussion started by: digioleg54
2 Replies

3. Shell Programming and Scripting

Uppercase to lowercase

Hello, I have a list of files in a directory whose names are all in uppercasse, including the file format for eg *.MP3 . I would like to convert these to the normal way we write it ie ABC.MP3 to be converted to Abc.mp3 . I know that this can be done manually by using a lot of "mv" or rename... (6 Replies)
Discussion started by: ajayram
6 Replies

4. Shell Programming and Scripting

Make the first character uppercase

Input: hello world monkey Output should be: Hello World Monkey How can it be done with perl,sed,awk or bash? (9 Replies)
Discussion started by: cola
9 Replies

5. Shell Programming and Scripting

Change to uppercase

Hi I have a string(can be mix of upper and lower case) and need the first three chars of the string to be converted to uppercase (4 Replies)
Discussion started by: Northpole
4 Replies

6. UNIX for Dummies Questions & Answers

UPPERCASE to lowercase

Hi All, i have a file and i want to convert all uppercase letters to lowercase letters which are in my file. how can i do this. Thanx (3 Replies)
Discussion started by: temhem
3 Replies

7. UNIX for Dummies Questions & Answers

uppercase to lowercase

i have no variable and no file i just want to convert AJIT to ajit with some command in UNIX can anybody help (4 Replies)
Discussion started by: ajit.yadav83
4 Replies

8. Shell Programming and Scripting

only uppercase first character?

should be a simple question, I am trying to uppercase every first character in a word on the list. abc google cnn services My first thought was sed 'y/^/^/', but it changed all the characters, not just the first character. any thoughts? (7 Replies)
Discussion started by: fedora
7 Replies

9. Shell Programming and Scripting

Converting to Uppercase

I want to convert string into uppercase string. How can i do that ? Ex: Enter the user name: read name show=upper(name) echo $show --- This output should be the uppercase output. Thanks (3 Replies)
Discussion started by: dreams5617
3 Replies

10. Shell Programming and Scripting

uppercase to lowercase

Greetings & Happy New Years To All! A client of mine FTP'ed their files up to the server and it all ended up being in UPPERCASE when it all should be in lowercase. Is there a builtin command or a script anyone knows of that will automagically convert all files to lowercase? Please advise asap... (4 Replies)
Discussion started by: webex
4 Replies
Login or Register to Ask a Question