[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to output data as null separated
From: |
TSHIMANGA Minkoka |
Subject: |
Re: how to output data as null separated |
Date: |
Mon, 16 Sep 2019 14:49:40 +0100 |
Hello Assaf,
You are right, the sed option -z also sets the null as record separator
in the output.
The documentation is not explicit on it, I do not know what distracted
me to not notice that while I was testing.
Thanks.
Tshimanga
On Sat, 2019-09-14 at 01:12 -0600, Assaf Gordon wrote:
> Hello,
>
> On 2019-09-11 1:35 a.m., TSHIMANGA Minkoka wrote:
> > I am aware of the sed -z option, that reads input with null
> > separated
> > "lines".
> > But how can I also similarly output null separated "lines".
>
> The "-z" option does exactly that:
> uses NUL as *both* input and output line separator.
>
> > My need is somehow a filenames piped processing, as outlined below.
> >
> > find /path -print0 | sort -z | sed -z --
> > needed_sed_option_to_output_null_separated_lines -e 'sed process 1'
> > -e 'sed process 2' | perl -n0 script.pl
>
> The about should "just work" (at least as far as sed is concerned).
>
> For example: the following uses "sed" to add a number before each
> line
> (still, NUL separated).
> Then perl reads each line and prints it.
> Note that perl's "-0" indeed only affects the input separator
> (unlike
> sed's "-z"):
>
> find . -print0 | sort -z | sed -z = \\
> | perl -n -0 -e 'print "line = $_\n";'
>
> regards,
> - assaf
>