Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed - delete blank lines between regular expression

Status
Not open for further replies.

gotchausa

Programmer
Jan 24, 2002
64
CA
How do I delete blank lines from lines containing certain wors/characters using sed? E.g:

Hello there
a

b
c
Bye bye

How can I delete the blank line between lines a and b?
 
I thought the point was to remove 'embedded' "blank" lines between the sequential "Member:" lines and NOT to remove ANY number of "blank" lines "preceeding" the "FGroup" lines.

The solution to remove ALL the blanks line and then add them manully does not sound like to satify the latter objective....

But if the "customer" is happy......

vlad

 
Sometimes the question that is asked isn't what is desired. That is why when the input file and desired output was shown, I was able to make some assumptions as what would be the best solution. You can beat your head trying to figure out the solution that fits exactly what the customer wants, but often (as in this case) you only need to meet the desired output.

Maybe the real lesson here is don't be so literal with your customers. You will save yourself a lot of grief if you know what they really want (even if they don't say so).

Cheers, Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
Depending on your approach.....

if you're trying to "hack" a task for a particular case of a more generic scenario - that's fine as long as you understand perfectly clear your assumptions and corresponding limitations.

If you feel that developing a more "generic" solution [including your current case] is something achievable and makes it a "challenging" task, why not go for it.....

On the other hand if the task "at hand" is too difficult to generalize, well.... we're back we've started.......

The "lesson" [in my view] is: be as specific as possible - I'll save yourself a lot of energy going over your old and often forgotten implementation time and time again removing "some assumptions as what would be the best solution".

vlad
 
Whatever - maybe I am a lazy programmer. I'll accept that. I don't have all the answers, infact I was pretty clueless on mpv's original question. However, once I saw that input file and the desired output file, the solution came to me.

I'm not saying that a more complex and specific solution wouldn't work, that may be desired. My simplistic approach may turn out to yield unexpected and undesireable results when implemented in production. I just saw the obvious gap and filled it.

I appologize if something I posted offended you. I visit tek-tips to learn more than share. But sometimes I get lucky. Einstein47
(Love is like PI - natural, irrational, endless, and very important.)
 
no offence taken!!!

I just grew up on comp.lang.awk where every post is looked on from the "theoretical" point of view exploring generic solutions. Based on my experience this approach has been the most fruitful in terms of the knowledge gain potential.

Sorry if I was a bit rough!

vlad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top