How to change Case of a string(BASH Scripting)?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to change Case of a string(BASH Scripting)?
# 1  
Old 07-09-2010
How to change Case of a string(BASH Scripting)?

Is there any inbuilt functionality in Unix shell script so that i can able to convert lower case string input to an upper case?

I dont want to use high level languages like java,python or perl for doing the job.
# 2  
Old 07-09-2010
Code:
print "${L_STRING}" | sed y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/


or

Code:
bash-2.05b$ echo "amit" |tr "[:lower:]" "[:upper:]" 
AMIT

This User Gave Thanks to amitranjansahu For This Post:
# 3  
Old 07-09-2010
awk '{ print toupper($0) }' file.txt
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting with case statement

Foe example we have three environments int,qa and prod.Each environment has some number of servers. int=Server1,Server2,Server3 qa=Server4,Server5,Server6 prod=Server7,Server8,Server9 echo "Enter the Environment i.e int,qa,prod" read env case $env in int) ## Need command where all the... (9 Replies)
Discussion started by: nareshreddy443
9 Replies

2. Shell Programming and Scripting

Change first letter of a word from lower case to upper case

Hi all, I am trying to find a way to change first letter in a word from lower case to upper case. It should be done for each first word in text or in paragraph, and also for each word after punctuation like . ; : ! ?I found the following command sed -i 's/\s*./\U&\E/g' $@ filenamebut... (7 Replies)
Discussion started by: georgi58
7 Replies

3. Shell Programming and Scripting

Need help to change tokenized string case

I'm trying to change the string cases for a particular column, but can't figure how do to it with sed. Example: Strings (space as delimiter): write group MYGROUP MySpecialGroup /local/users/mygroup write group HISGROUP HisSpecialGroup /local/users/hisgroup write group HerGroup... (3 Replies)
Discussion started by: fluffy_ko
3 Replies

4. Shell Programming and Scripting

{bash scripting} Multiline initialisation of string variable

Hello, The task is quite simple. I need to initialise а string variable and assign to it a very long value. For the reason of readability I want to devide this long value into equal parts and place each part at a separate line. For instance, I have - ... (1 Reply)
Discussion started by: Pretoria
1 Replies

5. Shell Programming and Scripting

Change case preserving the same case

how can i do a case insensitive search/replace but keep the same case? e.g., i want to change a word like apple-pie to orange-cake but for the first word if the first letter of the keyword or the letter after the - is capitalised i want to preserve that e.g., if the before is: ... (5 Replies)
Discussion started by: vanessafan99
5 Replies

6. UNIX for Dummies Questions & Answers

How to change the second to nth string in lower case

I have a file which contains something like this REIGN ANGEL i want to change REIGN to Reign and ANGEL to Angel. (6 Replies)
Discussion started by: reignangel2003
6 Replies

7. Shell Programming and Scripting

[Solved] Change Upper case to Lower case in C shell

Is there a command that can switch a character variable from UPPER case to lower case? like foreach AC ( ABC BCD PLL QIO) set ac `COMMAND($AC)` ... end Thanks a lot! (3 Replies)
Discussion started by: rockytodd
3 Replies

8. Shell Programming and Scripting

data array needs to change upper case to lower case

Hi all, i have a data array as followes. ARRAY=DFSG345GGG ARRAY=234FDFG090 ARRAY=VDFVGBGHH so on.......... i need all english letters to be change to lower case. So i am expecting to see ARRAY=dfsg345ggg ARRAY=234fdfg090 ARRAY=vdfvgbghh so on........ If i have to copy this data in... (8 Replies)
Discussion started by: usustarr
8 Replies

9. UNIX for Dummies Questions & Answers

change character case

i need to change character case inside a script file. How i can do that? any fucntion? thanks (3 Replies)
Discussion started by: ajaya
3 Replies

10. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies
Login or Register to Ask a Question