FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 01-13-2010, 03:44 AM
green
 
Default sed: adding lines before/after/inside line groups

My head is about to burst from trying to comprehend sed usage. Perhaps some
kind individual(s) will help me lest my mental capacity by surpassed.

I have a file that looks like this (please pardon the bad, fake lyrics):
---begin example---
Number: 001
Title: Advocacy

Verse:
Have you heard of Debian,
The OS that ran and ran?

Chorus:
Just download it free
To one of your CDs.

Verse:
You should try it;
You need not buy it.
Number: 005
Title: Another Song
---end example---

The original starts at a Number: line like the example, continues through n
lyric sets, and ends just before another Number: line. Lyrics may or not have
a chorus.

I want to convert these to a LyX format that I have established.

The Number: and Title: lines are easy enough to convert; only the Verse: and
Chorus: chunks (which may be 8 lines) are a problem. I need those chunks to
have:
- 1 line added before (different for verse/chorus)
- 2 lines added between lines
- 1 line added after (same for verse/chorus)
(More/fewer blank lines in output are okay).

The end of the Verse chunks are either a blank line or a Number: line.

Thanks for reading this far; last is an example of the output I am hoping for.

---begin example---
Number: 001
Title: Advocacy

egin_layout Verse
Have you heard of Debian,
egin_inset Newline newline
end_inset
The OS that ran and ran?
end_layout

egin_layout Chorus
Just download it free
egin_inset Newline newline
end_inset
To one of your CDs.
end_layout

egin_layout Verse
You should try it;
egin_inset Newline newline
end_inset
You need not buy it.
end_layout
Number: 005
Title: Another Song
---end example---
 
Old 01-13-2010, 10:57 AM
Eduardo M KALINOWSKI
 
Default sed: adding lines before/after/inside line groups

On Qua, 13 Jan 2010, green wrote:

My head is about to burst from trying to comprehend sed usage. Perhaps some
kind individual(s) will help me lest my mental capacity by surpassed.

I have a file that looks like this (please pardon the bad, fake lyrics):
[snip] example

I want to convert these to a LyX format that I have established.

The Number: and Title: lines are easy enough to convert; only the Verse: and
Chorus: chunks (which may be 8 lines) are a problem. I need those chunks to
have:
- 1 line added before (different for verse/chorus)
- 2 lines added between lines
- 1 line added after (same for verse/chorus)


It may be possible to do this in sed alone, but a more complete
scripting language, such as perl, python, ruby, etc. will probably
make the job easier, since you'll not be limited to processing each
line individually.


--
No man in the world has more courage than the man who can stop after
eating one peanut.
-- Channing Pollock

Eduardo M KALINOWSKI
eduardo@kalinowski.com.br


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 04:20 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org