sed - remove nul lines from file

Yuri Pankov yuripv at gmx.com
Tue Nov 7 18:03:37 UTC 2017


On Tue, 7 Nov 2017 13:01:12 -0500, James B  Byrne Via Freebsd-questions 
wrote:
> 
> On Tue, November 7, 2017 12:36, Yuri Pankov wrote:
>>
>> Apparently, our regex engine doesn't accept the '\x' syntax, try a bit
>> more complicated, but standard way :-)
>>
>> sed '/[[.NUL.]]/d'
>>
> 
> sed /[[.NUL.]]/g INFILE > OUTFILE

You want /d, not /g, to delete the *lines* which contain NUL symbols 
(that's what your subject line said).

> gives the same result as
> 
> tr < INFILE -d '\000' > OUTFILE
> 
> sed /^[[.NUL.]]$/g INFILE > OUTFILE  has no effect whatsoever.  No
> doubt because I am not specifying the record delimiters appropriately.
> 
> 




More information about the freebsd-questions mailing list