[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to output data as null separated

From: Assaf Gordon
Subject: Re: how to output data as null separated
Date: Sat, 14 Sep 2019 01:12:27 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0


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
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

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";'

 - assaf

reply via email to

[Prev in Thread] Current Thread [Next in Thread]