grep for ascii nul

andrew clarke mail at ozzmosis.com
Fri Nov 1 09:22:18 UTC 2019


On Fri 2019-11-01 09:48:17 UTC+0700, Victor Sudakov (vas at sibptus.ru) wrote:

> Dear Colleagues,
> 
> How can I print the names of files containing ascii nul (\x0)? The
> FreeBSD "grep -l" does not seem to be able to do it.
> 
> NB I don't need to delete the nul character with sed or tr, just need to
> find files containing it.

I don't believe FreeBSD (or Linux, Windows or even DOS) allows filenames
containing a null. Any regular C program that treats filenames as a
null-terminated string would correctly stop iterating over the string at the
first null.

Consequently two files named "Hello" and another named "Hello\0world" would be
seen as identical, leading to unpredictable results.


More information about the freebsd-questions mailing list