Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!amdahl!krs From: krs@uts.amdahl.com (Kris Stephens [Hail Eris!]) Newsgroups: comp.unix.shell Subject: Re: How to convert lower case variable into upper case? Message-ID: <2f7w01JR0fhl00@amdahl.uts.amdahl.com> Date: 25 Jan 91 02:16:35 GMT References: <530@twg.bc.ca> Reply-To: krs@amdahl.uts.amdahl.com (Kris Stephens [Hail Eris!]) Organization: Amdahl Corporation, Sunnyvale CA Lines: 69 How about: real_port=`echo "$Port" | sed 's/p$/P/'` If you *know* that the only character you need to change is a trailing lowercase-p into a Capital-P, that'll do it. In fact, if you're walking all of the lock-files and, let's say, you need to nail two characters, both trailing lowers (p and x) into Caps (P and X): ls /usr/spool/uucp/LCK..tty* 2>/dev/null | sed -e 's/p$/P/' \ -e 's/x$/X/' | while read lockfile do : # Whatever done or for lockfile in `ls /usr/spool/uucp/LCK..tty* 2>/dev/null | sed -e 's/p$/P/' -e 's/x$/X/'` do : # process this lockfile done Redirecting stderr to /dev/null on the ls command avoids stderr from the script when there just happen to be no tty lockfiles. It wasn't clear to me whether you've got lowercase last characters and need to switch 'em to Caps or you've got Caps and need to switch them to lowercase. Obviously, if you need to go from Caps to lower, you'll need to reverse the characters in the sed edits I list above. Here's an extension to make the /dev/tty filename out of the lockfile name. I just thought of this... Assumption: lockfiles ending in lowercase letters need to be converted to last-character-lower to get the ttyname. # # The sed script does the following: # load the hold space with the lockfile name # delete from ^ through "LCK.." # switch trailing lower-[px] to Cap-[PX] # insert /dev/ to make the device filename # append the lockfile name from the hold space # replace the newline (from G) with a blank # ls /usr/spool/uucp/LCK..tty* 2>/dev/null | sed -e 'h' \ -e 's/.*LCK..//' \ -e 's/p$/P/' \ -e 's/x$/X/' \ -e 's,^,/dev/,' \ -e 'G' \ -e 's/\n/ /' | while read device lockfile do : done ...Kris -- Kristopher Stephens, | (408-746-6047) | krs@uts.amdahl.com | KC6DFS Amdahl Corporation | | | [The opinions expressed above are mine, solely, and do not ] [necessarily reflect the opinions or policies of Amdahl Corp. ]