On Sun, 28 Feb 1999, PAUL TRACESKI wrote:

> I've been scratching my head over this one.  I have a list of data that I
> want to selectively edit prior to sorting.  The data is in two forms:
> 
> ABDC   111  */4 letters, 3 spaces, 3 digits
> ABCD   22    */4 letters, 3 spaces, 2 digits
> 
> I wish to add a leading 0 to the digits in the lines containing only two
>  digits, leaving the current 3 digit lines as is:
> 
> ABDC   111  */4 letters, 3 spaces, 3 digits
> ABCD   022  */4 letters, 3 spaces, 2 digits
> 
> I can add a leading zero to the digits in all lines with:
> 
> sed 's/   /   0/g' file1 > file2
> 
> Is there a way to set the address option for sed to just perform
> the editing on those lines matching a pattern:
> 
> / [0-9][0-9]/ or the negation of /[0-9][0-9][0-9]/
> 
sed 's/ \([0-9][0-9]\)$/ 0\1/' should do it

-- 
Mike <[EMAIL PROTECTED]>

Beauty seldom recommends one woman to another.

Reply via email to