mahy
April 6th, 2011, 03:42 PM
Hello,
I've got an unusual problem, I need to filter out matching lines of a file, but ALLOWING empty lines. Grep is behaving a little strange
cat file | grep '^$'
This works and of course ONLY prints empty lines. That's not what I want.
cat file | grep '^$ \| PATTERN'
This DOES NOT work and ONLY prints lines matching the "PATTERN", ignoring empty lines. Again, not what I want. I want BOTH the matching lines AND empty lines.
Many thanks in advance for any help!
I've got an unusual problem, I need to filter out matching lines of a file, but ALLOWING empty lines. Grep is behaving a little strange
cat file | grep '^$'
This works and of course ONLY prints empty lines. That's not what I want.
cat file | grep '^$ \| PATTERN'
This DOES NOT work and ONLY prints lines matching the "PATTERN", ignoring empty lines. Again, not what I want. I want BOTH the matching lines AND empty lines.
Many thanks in advance for any help!