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.