better sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...

better sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...

Post by J. Kelly Cunningh » Fri, 13 Jan 1995 20:02:15



How do I do this sort of thing with one instance of sed?
                sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...
             (Force everything of the form " x" to " X".)

Thanks, kc

 
 
 

better sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...

Post by S. Spencer S » Sat, 14 Jan 1995 10:12:10


(reply also mailed)


Quote:

>How do I do this sort of thing with one instance of sed?
>            sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...
>             (Force everything of the form " x" to " X".)

If you can tolerate a perl solution,

  perl -pe 's/(\s)([a-z])/\1\u\2/g' <file name>

or you can feed it input on stdin instead of specifying a file name,
just like sed.

This uppercases all characters that are immediately preceded by whitespace
(which does not include characters at the beginning of a line).

--
  S. Spencer Sun / Network Computing Devices, Z-Code Software Division    ____
  A friend is someone who understands your past, believes in your         \  /
  future, and accepts you just the way you are today.                      \/
  [source unknown]

 
 
 

better sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...

Post by Phil Cra » Tue, 17 Jan 1995 20:18:37



Quote:Cunningham) writes:

> How do I do this sort of thing with one instance of sed?
>            sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...
>              (Force everything of the form " x" to " X".)

> Thanks, kc

Depending on your sed:

        sed -e 's/\ a/\ A/g' -e 's/\ b/\ B/' .... infile

        sed -e 'y/\ a/\ A/' -e 'y/\ b/\ B/' ..... infile

or using a script file:

        sed -f sed.script infile

where the script contains:

        s/\ a/\ A/g       or     y/\ a/\ A/
        s/\ b/\ B/g       or     y/\ b/\ B/
        .
        .
and so on.

----
Phil Cramp

#include <std/disclaimer>

 
 
 

better sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...

Post by Kevin D. Cla » Wed, 18 Jan 1995 05:16:08


>   Newsgroups: comp.unix.questions

>   Date: 12 Jan 95 11:02:15 CST

>   How do I do this sort of thing with one instance of sed?
>               sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...
>            (Force everything of the form " x" to " X".)

Try:  sed -e s/\ a/\ A/g \
          -e s/\ b/\ B/g \
          -e s/\ c/\ C/g \
          ...

Or you could throw these commands into a file and use sed's "-f"
switch.

Or you could use perl's "\u" modifier, which IMHO is the neatest way
to solve this.

Mind if I warn you about something?  I don't know exactly what you're
doing, but I think that I have a good idea.  What happens if the word
that you are trying to capitalize begins on the beginning of the line?

(this is why I suggested perl -- I dislike doing non-interactive
multi-line editing with anything but perl)

Hope this helps!

-kevin

--

Cabletron Systems, Inc.
Durham, N.H. (USA)

 
 
 

better sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...

Post by Anan » Fri, 20 Jan 1995 04:51:26


simpler still ... try this

 tr '[a-z]' '[A-Z]' < input_file > output_file

this'll translate all lowercase to upper case ...

-anand



>>How do I do this sort of thing with one instance of sed?
>>                sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...
>>             (Force everything of the form " x" to " X".)

>  perl -pe 's/(\s)([a-z])/\1\u\2/g' <file name>

 
 
 

better sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...

Post by Michael C Tiern » Thu, 26 Jan 1995 22:02:02


 > simpler still ... try this
 >  tr '[a-z]' '[A-Z]' < input_file > output_file
 > this'll translate all lowercase to upper case ...
        The problem is that this is NOT what the poster had requested.
        Here's the quote of the original.  He/She/It wants the sequence
        to begin with a space.  What's wanted here is to capitalize
        every word, not the entire word.
 > >>How do I do this sort of thing with one instance of sed?
 > >>    sed s/\ a/\ A/g | sed s/\ b/\ B/g | ...
 > >>    (Force everything of the form " x" to " X".)
 
 
 

1. sed sed sed

On solaris 9 - why are there multiple copies of sed installed.  One in /usr/ucb
owned by the SUNWscpu third party package, /usr/xpg4/bin/sed by SUNWxcu4, and
one in /usr/bin owned by SUNWcsu.  I've looked on other Sun machines not
maintained by me and the same versions of sed are in the same place owned by the
same packages.

Why the multiple copies?

2. New guy on Solaris

3. . 2 sed FAQs, sed exes, sed cetras; URLs

4. Anyone running a Linux-based firewall thru ISDN?

5. SED SED SED...

6. How do I configure /dev/bpf0 ??

7. (sed 1q ; sed 2q) : no output from 2nd 'sed'

8. New User

9. . sed script dc greg ubben sed stud

10. to all sed hackers - joining lines with sed

11. aix 3.2 - see sed run, run sed run

12. another tough sed problem: sed dependency

13. String manipulation error & how to use sed in a sed command?