sed

sed

Post by Boris Varshavs » Fri, 19 Nov 1993 03:01:50



Hi, Netters!

I'm really upset.
I was trying to use the following "sed" command:
sed 's/\(.\{10\}\).*/\1/' file_name
Instead of giving me first ten characters of every line it prints whole lines.
When I try
sed 's/\(..........\).*/\1/' file_name
it works fine.
Our DEC computer is running ULTRIX 4.3
When I do the same thing on SUN 670 both(!) commands work fine.
So is it a common ULTRIX/sed problem or just my own?
(Yes, I know how to get first 10 chars differently, I just simplified the
problem. I need to run a complicated "sed" command and do not want to count
dots).
Any help would be greatly appreciated.
--
---------------------------------------------------------------

 Software Engineer       Columbia University    |      it     |
 voice: 212-854-8928      fax: 212-316-9068     |         be! |

 
 
 

sed

Post by David W. Tamk » Fri, 19 Nov 1993 16:24:29




| I was trying to use the following "sed" command:
| sed 's/\(.\{10\}\).*/\1/' file_name
| Instead of giving me first ten characters of every line it prints whole lines.
| When I try
| sed 's/\(..........\).*/\1/' file_name
| it works fine.
| Our DEC computer is running ULTRIX 4.3
| When I do the same thing on SUN 670 both(!) commands work fine.
| So is it a common ULTRIX/sed problem or just my own?

Most seds do not understand the \{ \} notation.  The sed on your 670 is an
exception, but the sed on your ULTRIX machine is making the substition only
on lines that contain "{10}" (but not if it's at the left margin).  No line
in your file has that sequences, so all lines are output without substitu-
tion.  Add the -n option to the sed command and the p flag to the s instruc-
tion and you'll see the difference.

Use cut instead if you have it.  It doesn't make you count dots either.

David W. Tamkin  P. O. Box 3284  Skokie, Illinois  60076-6284


 
 
 

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. strange load peaks with recent kernels

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

4. ram: No space on device on device 31/50

5. SED SED SED...

6. no startx in Debian 3.0

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

8. Can Linux use 36-bit Xeon addressing?

9. . sed script dc greg ubben sed stud

10. to all sed hackers - joining lines with sed

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

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

13. another tough sed problem: sed dependency