• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: do shell script- sed conundrum
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do shell script- sed conundrum


  • Subject: Re: do shell script- sed conundrum
  • From: "Mark J. Reed" <email@hidden>
  • Date: Fri, 17 Feb 2006 13:04:19 -0500

Uhm, so why use sed?  Just use perl.  perl -ne 's/.../.../' filename
   does what sed 's/.../.../' filename does.

However, your regex looks wrong.  s/\BTitle:/Title:\r" will turn
"Title: King KongTitle: Godzilla" into
"Title: King KonTitle:
 Godzilla".

You want to 1. keep whatever the \B matches and 2. put the newline
*before* the word Title.

perl -ne 's/(\B)(Title)/$1\n$2/' title.txt



On 2/17/06, Eric Geoffroy <email@hidden> wrote:
> This is a tiny part of a sed script that I'm calling from 'do shell
> script' This is the misbehaving part.
>
>
> SOURCE
> Title: King KongTitle: Godzilla
> Title: Mothra
>
> DESIRED RESULT
> Title: King Kong
> Title: Godzilla
> Title: Mothra
>
> I worked out the regex to match '\BTitle: '
> to negate the word boundary. In sed though, the boundary is \<
> but I can't figure out how to negate that.
>
> In my make-believe world, this would work-
>
> sed 's/\BTitle:/Title:\r/' title.txt
>
> I also tried ^\<(Title)
>
> In the real world, the \B is invalid for sed, and the shell in OSX is
> not handling the \r.
>
> thx
> - Eric
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>


--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: do shell script- sed conundrum
      • From: Christopher Nebel <email@hidden>
    • Re: do shell script- sed conundrum
      • From: "Mark J. Reed" <email@hidden>
References: 
 >do shell script- sed conundrum (From: Eric Geoffroy <email@hidden>)

  • Prev by Date: do shell script- sed conundrum
  • Next by Date: Re: do shell script- sed conundrum
  • Previous by thread: do shell script- sed conundrum
  • Next by thread: Re: do shell script- sed conundrum
  • Index(es):
    • Date
    • Thread