sed question

sed question

Post by Richard C. Mil » Sun, 21 Nov 1993 23:20:03



I am trying to place spaces on both sides of the '(' character everywhere
it occurs on a line.

example:  /datab/lo(rs1:

I have been trying it this way: echo "$line" | sed "s/\(/\ (\ /g"

                        Thanks for any help,

                        Richard Mills

===================================            
||Richard Mills                  ||        
||System Administrator           ||
||Harris Controls Division       ||        
||Melbourne Florida              ||      
||(407)242-5324                  ||        

===================================

 
 
 

sed question

Post by Harald Schroepf » Mon, 22 Nov 1993 03:21:20



Quote:> I am trying to place spaces on both sides of the '(' character everywhere
> it occurs on a line.

> I have been trying it this way: echo "$line" | sed "s/\(/\ (\ /g"

                                  echo "$line" | sed "s/(/ ( /g"

                                                                  as "(" is not special in sed's REs
                                                                  whereas "\(" is . Wouldn't
                                                                                                sed 's/[^ ](/ (/g
                                                                                                         s/([^ ]/( /g'
                                                                  be better? Avoids doubling spaces.

Quote:

>                    Thanks for any help,

>                    Richard Mills


 
 
 

sed question

Post by Shimon Schreib » Tue, 23 Nov 1993 15:18:14


Quote:> I have been trying it this way: echo "$line" | sed "s/\(/\ (\ /g"

Why all these backslashes ? don't need them:
% echo "a(b(c))" | sed "s/(/ ( /g"
a ( b ( c))

Hope this helps (should be abbreviated in this here newsgroup to hth?)

--

Tel: Intl+972+4-313610
Disclaimer: This message will destroy itself in 5 seconds.

 
 
 

1. yet another sed question ...

Hi all, I need to extract the latest RCS version numbers directly from
a bunch of RCS files.  The first lines of those files are all in the
form of "head 1.20;" where 1.20 (or some other number) is the number I
want to extract.

I tried the following command in my sh script:

  head -1 filename | sed -n 's/^head *\([0-9]*\.[0-9]*\)/\1/p'
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

but nothing came out.  The result from "head -1 filename" in this case
is "head    1.20;".  Couldn't figure out while, I tried at command
line the following:

  echo "head    1.20;" | sed -n 's/^head *\([0-9]*\.[0-9]*\)/\1/p'
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and got the correct result "1.20".  BTW, I tried the first form on
command line too.

Can some enlighten me while the world the first form didn't work?

I'm currently using :

  head -1 filename |awk '{print $2}' |awk -F";" ' {print $1}'

it works but obviously not efficient.

Thanks for any help!

Rose Sun

2. Apache Webserver Configuration(problem)

3. newbie sed question

4. Yggdrasil install: "crc error"

5. sed question

6. Linux: undeletable file???

7. One more sed question...

8. ppp question(s)

9. another sed question

10. SED Questions

11. sed question

12. Sed question for newbie

13. Sed Question