Converting the case of the string?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Converting the case of the string?
# 1  
Old 07-09-2007
Converting the case of the string?

Hi

i have a string value in a variable STR
eg. STR="ABSDSCSFS"

How can be convert it to LOWERCASE in the script?

Thanks
# 2  
Old 07-09-2007
One way using tr is

Code:
echo "$STR" | tr '[:upper:]' '[:lower:]'

# 3  
Old 07-09-2007
Hi

What to do if we want permanent change in STR not just echoing like below??????

Quote:
Originally Posted by vino
One way using tr is

Code:
echo "$STR" | tr '[:upper:]' '[:lower:]'

# 4  
Old 07-09-2007
Code:
STR=$(echo "$STR" | tr '[:upper:]' '[:lower:]')

Regards
# 5  
Old 07-09-2007
Please refer to the link,
https://www.unix.com/unix-for-dummies...uppercase.html

You can use typeset.

Thanks
Nagarajan G
# 6  
Old 07-09-2007
Thanks !!!!!!!!!!!!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting String To Integer/Float (weird case)

Hi guys, I'm new here. I have a problem at work. One of our scripts was eventually having a bug and only detected recently. Here's the issue and background: Bash Script which calls AWK script Awk script returns a string as per below (example):var1='00000-123'So, when we convert it, the... (18 Replies)
Discussion started by: sekfarok
18 Replies

2. Shell Programming and Scripting

Converting string to integer

I have a function that is supposed to check for user processes and wait for 0 count before exiting the function. I am sure I have more than one issue in my code, but the stumbling block right now is that I am trying to convert the value of my variable from a string to integer. process_count... (10 Replies)
Discussion started by: MIA651
10 Replies

3. Shell Programming and Scripting

converting to lower case or upper case

here is a code column_name="vivek" column_name2="ViVeK" column_name=$(echo $column_name | awk '{print tolower($0)}') column_name2=$(echo $column_name2 | awk '{print tolower($0)}') echo "column name 1 lower: $column_name" echo "column name... (6 Replies)
Discussion started by: vivek d r
6 Replies

4. Shell Programming and Scripting

Converting integer to String

Hi everyone, I would like to know how to convert an integer to a string. for instance if i=1 i would like to creat a variable called constant1. i want to do this in a for loop so for each value of i, i create a new variable such as constant2, constant3,... and so on. for i in 1 2 3 do ... (1 Reply)
Discussion started by: ROOZ
1 Replies

5. UNIX for Dummies Questions & Answers

Perl - converting selected characters to upper/lower case

Using STDIN, how can I use perl to take an input string, with all lower case letters in the first five characters, and convert them to uppercase... then take all uppercase letters in the second five characters and convert them to lowercase. Example: MichaelSmith to michaELSMIth Thank you! (2 Replies)
Discussion started by: doubleminus
2 Replies

6. Programming

converting character string to hex string

HI Hi I have a character string which contains some special characters and I need it to display as a hex string. For example, the sample i/p string: ×¥ïA Å gïÛý and the o/p should be : D7A5EF4100C5010067EFDBFD Any pointers or sample code pls. (5 Replies)
Discussion started by: axes
5 Replies

7. Shell Programming and Scripting

Converting file names to upper case

Hi all, I am trying to rename all my files in a directory to their upper case counterparts .... I want to do this in a single command and not through shell script ... I started off thinking it wud be simple but got stuck up in middle since tr does not work the way i thought ... This is what i... (5 Replies)
Discussion started by: Sabari Nath S
5 Replies

8. Shell Programming and Scripting

command for converting string to integer

Hi ... I am trying to calculate the time needed for a command to execute.. but the resulting value is getting as string.. so i am not able to use "expr " command.. please help me to convert the value to integer so that i can proceed with my script.. Regards esham (1 Reply)
Discussion started by: esham
1 Replies

9. Shell Programming and Scripting

converting string to unicode

How can I can convert a string in a shell script that looks something like: ]] to unicode equivalent? thanks a lot, webtekie (1 Reply)
Discussion started by: webtekie
1 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