13

Sed delete blank lines upto first pattern match

view full story
linux-howto

http://www.unix.com – Hi Im trying to do the following in sed. I want to delete any blank line at the start of a file until it matches a pattern and then stops. for example: Input Quote: 1 2 3 4 pattern: 5 output: Quote: 1 2 3 4 pattern: 5 I have got it to work within a range of two patterns with the following: sed '/1/,/pattern/{/^[[:blank:]]*$/d}' The problem is that it will carry on in the file and if there is another match it will act on that. I only want it to act once. (HowTos)