Upper/Lower case

Upper/Lower case

Post by Barbara Colli » Mon, 28 Aug 1995 04:00:00



I have been using a series of global statements inside a shell script to
convert upper case to upper/lower. I have encountered difficulty in two
statements.  I can use g/ O /s// O' /g to insert apostrophe after O space,
but I cannot figure out how to prevent the aprostrophe after the O if there are
two or more spaces after.  Also I would like to know how to move Mac Donald
together and put a space after Donald to make sure I have the same amount
of spaces on a line. I need to read this back into a data file for data
processing.

thanks for any help,
Barbara

 
 
 

Upper/Lower case

Post by Bill Marc » Tue, 29 Aug 1995 04:00:00




>I have been using a series of global statements inside a shell script to
>convert upper case to upper/lower. I have encountered difficulty in two
>statements.  I can use g/ O /s// O' /g to insert apostrophe after O space,
>but I cannot figure out how to prevent the aprostrophe after the O if there are
>two or more spaces after.  

Can you assume that O followed by two or more spaces is an initial?  If
so, you could use s/ O  / O. /
Quote:>Also I would like to know how to move Mac Donald
>together and put a space after Donald to make sure I have the same amount
>of spaces on a line. I need to read this back into a data file for data
>processing.

Can you be sure that Mac is always part of the last name?  This might be
a job for manual editing.

Quote:>thanks for any help,
>Barbara

--

SEX IS NOT *, CENSORSHIP IS!

 
 
 

Upper/Lower case

Post by Ravi Channavajha » Tue, 29 Aug 1995 04:00:00



Quote:

>I have been using a series of global statements inside a shell script to
>convert upper case to upper/lower. I have encountered difficulty in two
>statements.  I can use g/ O /s// O' /g to insert apostrophe after O space,
>but I cannot figure out how to prevent the aprostrophe after the O if there are
>two or more spaces after.  Also I would like to know how to move Mac Donald
>together and put a space after Donald to make sure I have the same amount
>of spaces on a line. I need to read this back into a data file for data
>processing.

>thanks for any help,
>Barbara

Why not AWK for this kind of stuff??  What you need is a very simple
awk script to do this kind of stuff.

awk '
        BEGIN { UP="A..Z"
                LO="a..z"
                }
# I am assuming that your data is delimited by spaces,  n could be 1 or 2 etc.,
        TO_UP=substr($n,1,1)
        CHAR_NO=index(TO_UP,LO)
        if (CHAR_NO > 0)
                {
                UP_CHAR=substr(UP,TO_UP,1)
                $n=UP_CHAR substr($n,2)
                }
        else
                Print "Unable to process this line of data " $0 >> error
        next
# this converts the first character of $n to its upper case...in a flash

for names like Mac Donald

I'm assuming that your data is organized like this

John Mac Donald blah 123 blah etc.,

all you do is STR=$2 $3, this concatanates the third space delimited to second
field to the variable STR.

-Ravi.

 
 
 

Upper/Lower case

Post by Nikhil Pat » Wed, 30 Aug 1995 04:00:00


: I have been using a series of global statements inside a shell script to
: convert upper case to upper/lower. I have encountered difficulty in two
: statements.  I can use g/ O /s// O' /g to insert apostrophe after O space,
: but I cannot figure out how to prevent the aprostrophe after the O if there are
: two or more spaces after.  Also I would like to know how to move Mac Donald
: together and put a space after Donald to make sure I have the same amount
: of spaces on a line. I need to read this back into a data file for data
: processing.

: thanks for any help,
: Barbara

Try this:
1. g/ O [^ ]/s// O' /g
2. g/Mac Donald/s//MacDonald /g

Nikhil.

 
 
 

Upper/Lower case

Post by hal.. » Thu, 31 Aug 1995 04:00:00


- I have been using a series of global statements inside a shell script to
- convert upper case to upper/lower. I have encountered difficulty in two
- statements.  I can use g/ O /s// O' /g to insert apostrophe after O space,
- but I cannot figure out how to prevent the aprostrophe after the O if there
- are two or more spaces after.
If it were "sed", this would work:
        s/\( O\)\( [^ ]\)/\1'\2/
(better to put it into a file, with all that quoting/escaping in it).
- Also I would like to know how to move Mac Donald together and put a space
- after Donald to make sure I have the same amount of spaces on a line.
sed:
        s/Mac \([^ ]*\)/Mac\1 /
 
 
 

Upper/Lower case

Post by Barbara Colli » Thu, 31 Aug 1995 04:00:00


I am still trying to find an answer to a couple of statements in an ex script
to convert Upper to Upper/Lower.
I would like to know how I can move any name that starts with Mc or Mac
together and put a space after the second part of Name.
To Nikhil,
  I tried
     g/ O [^ ]/s// O' /g
   This does not put ' on anything. I need it to put ' between a name like
O'Henry but not on Apt O.
  MacDonald works, but I wanted to grep anything that starts with Mac space to
  move together.
   Thanks for any help
    Barbara
 
 
 

1. HowTo Translate to Upper/Lower case ?

Hi all,
to deal with oracle i need to have a var ORACLE_SID to be in UPPER
case. But when checking AIX Filesystems i need the same value in LOWER
case.
So, how can i translate the values ?

Something like:
value=abcd or ABCD or maybe mixed case ? aBcD
ORACLE_SID=UPPER(<value>)
FS="/dev/"LOWER(<value>)"dblv"

Thanks
Andreas
Andreas Wizemann

2. net commands

3. Pb with upper/lower case (VisionFS)

4. unblocking a parent shell after it launches a subshell

5. How to grep without no regard to Upper/Lower case?

6. Can't write to tape using tar

7. UPPER/lower case conversion

8. NFS uid and gid mapping ?

9. Samba(upper-lower-case) or NFS(encrypted passwords)

10. text console login, how to fix reversed upper/lower case?

11. Problem/conflict with upper/lower case file name

12. UPPER-lower case logins

13. upper/lower case filenames question