|
From: | František Kučera |
Subject: | Re: [Help-bash] Readig multiple null-separated values |
Date: | Thu, 1 Aug 2019 15:54:46 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
Dne 29. 07. 19 v 10:01 David napsal(a):
On Sat, 27 Jul 2019 at 23:56, František Kučera <address@hidden> wrote:in my Bash pipelines I sometimes pass data separated by null byte \0 and it is not only lists (like in find -print0) but matrices/tables/relations with fixed number of columns/attributes. The \0 is used to both separate values and records. The advantage is that the only forbidden character in values is the \0 and there are no collisions with text separators like ,;:\t\n etc. and no need for escaping or quoting. So it is a safe and simple way to pass structured data between processes.When you use the word "data" above, do you mean ASCII text, or something else?
It is usually UTF-8 text and it could come from various sources like databases, XML, filesystem (file names, extended attributes or file content).
If ASCII text, are you aware of the ASCII delimiter characters? See https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
I know about them, but as already mentioned by others, such characters might occur inside the value. And the only character that could not occur in a filename or C string is \0. However it is a corner-case and ASCII delimiters would mostly work.
Franta
[Prev in Thread] | Current Thread | [Next in Thread] |