[sword-devel] shell help

DJ Ortley djortley at gmail.com
Thu Nov 19 01:08:28 MST 2009


Try putting this in an executable script (change the #!/.. line to
your sed's path) and pass the file as an argument:

#!/usr/bin/sed -f

# Range is from a blank line to <SB>.+
/^$/,/<SB>.+$/ {

   # Sub a blank line with <SB>\n
   s/^$/<SB>\
/

  # Find <Page.*, and swap with the line below
  /<Page.*/ {
    N
    s/\(<Page.*\)\n\($$$.*\)/\2\
\1/
  }

  # Kill the <SB> (I don't know why .* instead of .+ only works.)
  s/^<SB>\(.*\)$/\1/

}
########## End of Sed script

Let me know if it works.

-DJ

On Thu, Nov 19, 2009 at 12:40 AM, Troy A. Griffitts
<scribe at crosswire.org> wrote:
> Hey guys,
>
> I'm trying to setup a reproducible process to convert the Tregelles data
> to a SWORD imp data time.  I have a series of sed commands to replace
> tags, etc.... (yeah, yeah. I'm sure perl could do it in one line...)
>
> But anyway, I've got one problem left that I could use some help with:
>
> Here is a worst case real sample pattern:
>
>
> ...υντελείας τοῦ αἰῶνος.
>
> <Page = 119><Title = ΕΥΑΓΓΕΛΙΟΝ ΚΑΤΑ ΜΑΡΚΟΝ.>
> $$$Mark.1.1
> <SB>Ἀρχὴ τοῦ εὐαγγελίου Ἰησοῦ χριστοῦ υἱοῦ θεοῦ·
>
>
> It needs to become:
>
> ...υντελείας τοῦ αἰῶνος.
> <SB>
>
> $$$Mark.1.1
> <Page = 119><Title = ΕΥΑΓΓΕΛΙΟΝ ΚΑΤΑ ΜΑΡΚΟΝ.>
> Ἀρχὴ τοῦ εὐαγγελίου Ἰησοῦ χριστοῦ υἱοῦ θεοῦ·
>
> So, the rules in pros:
>
> <SB> which start a new line must be moved to the end of the
> non-zero-length line preceding the previous $$$
>
> ^<Page = [^>]*><Title = [^>]*>$ lines must be moved down just below the
> next $$$ line.
>
>
> Any help would be appreciated.  Preferably with something like awk (I
> don't think sed can work multiline can it?)  I guess perl would be ok too :)
>
>
> Thanks for any help,
>
>        -Troy.
>
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page



More information about the sword-devel mailing list