The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl - converting selected characters to upper/lower case doubleminus UNIX for Dummies Questions & Answers 2 05-19-2008 02:13 AM
Accepting Upper and Lower case lweegp Shell Programming and Scripting 8 12-08-2007 06:57 PM
copy "cp" command how distinquish upper/lower case bobk544 UNIX for Dummies Questions & Answers 1 09-17-2007 12:46 PM
lower case to upper case string conversion in shell script dchalavadi UNIX for Dummies Questions & Answers 3 05-29-2002 01:07 AM
Upper And Lower Case pciatto Shell Programming and Scripting 1 04-29-2002 01:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-09-2007
rfourn rfourn is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 4
UNIX command to reverese lower and upper case

im trying to find a command to
change all upper case to lower case and
all lower case to upper case.
for example:
file is 'RED sox'
need it changed to 'red SOX'

tried tr 'a-zA-Z' 'A-Za-z' didn't work

what an i missing??

thanx for the help
  #2 (permalink)  
Old 06-09-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
I tried


Code:
tr "a-zA-Z" "A-Za-z"

and that worked on Etch.
  #3 (permalink)  
Old 06-09-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
I would expect it to work with single quotes as well:
Code:
$ echo RED sox | tr 'a-zA-Z' 'A-Za-z'
red SOX
$

rfourn, what version of Unix are you using? And what shell?

The pre-posix USG based version of tr used to require brackets around a range. On such a version,
tr '[a-z]' '[A-Z]'
would work for sure. I don't remember for sure if multiple ranges would work, but I think they did. If so,
tr '[a-z][A-Z]' '[A-Z][a-z]'
would work. BSD never required the brackets and Posix adopted the BSD style for ranges. Legacy USG scripts will tend to work with a Posix version of tr because with
tr '[a-z]' '[A-Z]'
brackets are being replaced by themselves. A legacy USG scrip with code like:
tr 'a-z'
where the 'a-z' is supposed to be exactly 3 characters will fail though.

I hope you aren't using a very old version of Unix with behavior like this. But if you are, it is especially crucial that you mention your Unix version with every question.
  #4 (permalink)  
Old 12-07-2007
ramkrix ramkrix is offline
Registered User
  
 

Join Date: Dec 2007
Location: TamilNadu,INDIA
Posts: 52
Exclamation

Hi version of UNIX is SOLARIS 9

but neither of the aforesaid commands is working..

Will you suggest how to execute the same in SOLARIS9?
  #5 (permalink)  
Old 12-07-2007
V3l0 V3l0 is offline
Registered User
  
 

Join Date: Nov 2007
Location: Belgium & France
Posts: 70
echo RED sox | tr '[:upper:][:lower:]' '[:lower:][:upper:]'
red SOX
  #6 (permalink)  
Old 12-07-2007
prowla prowla is offline
Read Only
  
 

Join Date: Nov 2007
Posts: 165
Works for me on HP-UX, Solaris, and Cygwin on Windoze.

# uname -a
SunOS mysun 5.10 Generic_118833-17 sun4v sparc SUNW,Sun-Fire-T200# echo RED sox | tr 'a-zA-Z' 'A-Za-z'
RED sox

# uname -a
HP-UX myhp B.11.11 U 9000/800 158454601 unlimited-user license
# echo RED sox | tr 'a-zA-Z' 'A-Za-z'
red SOX

$ uname -a
CYGWIN_NT-5.0 mypc 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
$ echo RED sox | tr 'a-zA-Z' 'A-Za-z'
red SOX
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0