Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!fub!opal!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.unix.shell Subject: Re: How to convert lower case variable into upper case? Message-ID: <1075@mwtech.UUCP> Date: 30 Jan 91 21:02:54 GMT References: <530@twg.bc.ca> <553@twg.bc.ca> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 47 In article <553@twg.bc.ca> bill@twg.bc.ca (Bill Irwin) writes: >I asked for a way to convert the name of a uucp lock file into >its upper case counterpart /dev device name. Since you don't >know which modem ports might be in use, those solutions that had >a particular letter "wired" in have limited value. > >I received several mailed responses. The simplest and most >easily understandable (by me), provided by Stuart Hood, follows: > >case $modem in > i[1-9][a-z]) > real_modem=i`echo $modem | sed 's/i//' | tr '[a-z]' '[A-Z]'` > ;; >esac Hmmm, judging from the numerous followups the original questions seems to draw a lot of answers. As someone else allready metioned the y-command of sed to simplify the above, I'll turn back from this and related ways to solve the problem to another "no sub-processes" solution. Like the original way with "case-in" the following has the limitation that you must set up all the expected names in advance, but this time as shell variables, not as case labels: i0p=i1P i1p=i1P i2p=12P ....etc... Then use eval 'real_modem='$modem . Note that setting up the required variables can be also done in a loop: for i in 0 1 2 3 4 5 6 ...... do eval 'i'$i'p=i'$1'P done Another idea would be to avoid the variables and do it all in a loop: for i in 0 1 2 3 4 5 6 ...... do case $modem in i${i}p) real_modem=i${i}P esac done -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83