sed - remove nul lines from file

Tim Daneliuk tundra at tundraware.com
Tue Nov 7 19:00:30 UTC 2017


On 11/07/2017 12:14 PM, James B. Byrne via freebsd-questions wrote:
> Sigh.  Thank you.  That works.  However, it also deletes any line that
> has even one NUL in it regardless of the presence of other non-nul
> characters on the line.

Methinks we need a more rigorous statement of reqirements here :)
To whit:

- A 'line' is something that  ends with "\n".

- Any line that _only_ contains one or more NULL chars is to be removed
  entirely.

- Any line that contains one or more NULL chars _and_ other chars is
  to have those NULLs removed, leaving the remainder of the line intact.

- An empty line ("\n" only) is to be left untouched.

Is that correct?

-- 
----------------------------------------------------------------------------
Tim Daneliuk     tundra at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/



More information about the freebsd-questions mailing list