On Friday 31 March 2006 08:50, [EMAIL PROTECTED] wrote:
> I have a bunch of test files with lines of the form
>
> **1.** Scope
>
> or
>
> **2.2** Uniforms and other clothing worn in the production area must be
> laundered regularly. Additional clothing changes may be required when
> significant soiling occurs, especially when involved in 'dirty' cleaning
> or maintenance.
>
> The ones that have no digit after the decimal place I want to change to
> the form
>
> **1. Scope**
>
> I wrote the following
>
>  sed -i.bak "s/^\(\*\*[0-9][. ]\)\*\*\(.*\)$/\1\2**/" *.txt
>
> Unfortunately sed seems to be putting the 2 trailing ** at the beginning
> of the replacement line rather than the end of the line and after much
> stuffing around I still can't work out what is going wrong.
>
> If I leave out the $ in the regex to match then I get ^M embedded into
> the replacement string i.e "**1. Scope^M**"
>
> Can anyone see what I am doing wrong?

Your regex looked fine, so my curiosity was piqued. This was my input:
----------------------------------------------------------------------
**1.** Scope

**2.2** Uniforms and other clothing worn in the production area must be
laundered regularly. Additional clothing changes may be required when
significant soiling occurs, especially when involved in 'dirty' cleaning
or maintenance.
----------------------------------------------------------------------

this my output
----------------------------------------------------------------------
**1. Scope**

**2.2** Uniforms and other clothing worn in the production area must be
laundered regularly. Additional clothing changes may be required when
significant soiling occurs, especially when involved in 'dirty' cleaning
or maintenance.
----------------------------------------------------------------------

[tigger] /home/jam [55]% rpm -qa |grep sed
sed-4.1.4-3

James
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to