Change sed line separator to NUL to act as "xargs -0" prefilter?

Viewed 5010

I'm running a command line like this:

filename_listing_command | xargs -0 action_command

Where filename_listing_command uses null bytes to separate the files -- this is what xargs -0 wants to consume.

Problem is that I want to filter out some of the files. Something like this:

filename_listing_command | sed -e '/\.py/!d' | xargs ac

but I need to use xargs -0.

How do I change the line separator that sed wants from newline to NUL?

4 Answers

With help of Tom Hale and that answer we have: sed -nzE "s/^$PREFIX(.*)/\1/p"

Related