Change to uppercase


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change to uppercase
# 1  
Old 11-18-2010
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
# 2  
Old 11-18-2010
try this,
Code:
echo "teStforyou" | awk '{print toupper(substr($0,1,3))substr($0,4)}'

# 3  
Old 11-18-2010
if you have ksh 93 you can use:

Code:
typeset -u F3
STR="teStforyou"
F3=${STR:0:3}
STR=${F3}${STR:4}

# 4  
Old 11-18-2010
With GNU sed
Code:
$ echo "teStforyou" | sed 's/\(^...\)/\U&/'
TEStforyou

# 5  
Old 11-19-2010
Code:
v=kerflooey
echo "$( echo "${v%${v#???}}" | tr '[:lower:]' '[:upper:]')${v#???}"


Last edited by Scrutinizer; 11-19-2010 at 12:06 PM..
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. UNIX for Dummies Questions & Answers

Change Uppercase to Lowercase with some exceptions

I need to change instances of uppercase to lowercase. The change occurs only when all of the characters are capital letters. For instance, if the following was contained in the file: THE BRIGHT DAY it should be: the bright day However: The BRIGHT day should remain the same. Also, if it were... (3 Replies)
Discussion started by: kcgb20
3 Replies

3. 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

4. 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

5. AIX

Lowercase to Uppercase

Inside a script I have 2 variables COMP=cy and PT=t. further down the same script I require at the same line to call those 2 variables the first time uppercase and after lowercase ${COMP}${PT}ACE,${COMP}${PT}ace. Can somebody help me Thanks in advance George Govotsis (7 Replies)
Discussion started by: ggovotsis
7 Replies

6. UNIX for Dummies Questions & Answers

Change date to uppercase

Hello, I'm trying to take a 3 character date and change it to uppercase, does anyone know how to do that? Currently, all commands that I know of for changing strings/variables to uppercase change the command itself to uppercase, not the output. Here is what I've tried: date="date... (2 Replies)
Discussion started by: tekster757
2 Replies

7. UNIX for Dummies Questions & Answers

Need to change filenames in a particular directory from lowercase to UPPERCASE

Hi, I need a shell script which changes a bunch of files in a particular directory from lowercase to UPPERCASE. I am not very familiar with shell scripts so a detailed explanation would be greatly appreciated!!!! Thanks ini advance! :) (7 Replies)
Discussion started by: Duke_Lukem
7 Replies

8. UNIX for Dummies Questions & Answers

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 (4 Replies)
Discussion started by: kirkm76
4 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