[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: echo $'\0' >a does not write the nul byte
From: |
Eduardo Bustamante |
Subject: |
Re: echo $'\0' >a does not write the nul byte |
Date: |
Sun, 17 Jan 2021 12:20:47 -0800 |
On Sun, Jan 17, 2021 at 12:05 PM <hans@artax.karlin.mff.cuni.cz> wrote:
> (...)
> The nul byte is not echoed by $'\0'.
This is expected. Bash uses NUL-byte terminated character sequences to
store strings, so it can't actually store NUL bytes themselves.
$'\0' is the same as '' (i.e. an empty string).
If you want to output an actual NUL byte, try using:
printf '\0'
Instead