Jack Schwartz wrote:
> Hi everyone.
> 
> Here is a revised webrev of code to get rid of the Hard Disk entry in 
> the grub menu for USB sticks.
> 
> Try as I might, I couldn't figure out a way using sed to do what I 
> needed to do.  So, instead I wrote a function to do it: it looks for 
> lines with "Hard Disk" in them, and then deletes until either a blank 
> line is seen or the word "title" appears at the beginning of a line.  
> "Title" lines are kept in;  blank lines are deleted.
> 
> http://cr.opensolaris.org/~schwartz/081112.1/webrev/
> 
> It's not a one-liner anymore, but should be straightforward enough...
> 

It's OK, but I do recommend getting to know nawk; it does a lot more 
than sed, much more compactly than the shell:

nawk '
BEGIN { inhard=0 }
/^title.*Hard Disk$/ { inhard=1 }
/^title/ { if (index($0,"Hard Disk") == 0) inhard=0 }
inhard == 0 {print}
' menu.lst

does exactly what you want.

Dave

Reply via email to