[Top][All Lists]

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

RFC: yes as a filter

From: Eric Blake
Subject: RFC: yes as a filter
Date: Wed, 17 Feb 2016 23:42:05 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

I found myself wanting to reproduce a line of input multiple times, so
my first thought was:

echo line | yes --some-option | consumer

to make yes read the first line of stdin and replay that, but we don't
have such an option - the text to be replayed has to be passed on the
command line. I ended up doing:

yes "$(echo line)" | consumer

but wonder if it is worth adding such an option (maybe spelled
--from-file, where '--from-file=-' reads from stdin).  Using xargs for
the task is not ideal, unless we have a way to make xargs shut up about

# echo line | xargs yes | head -n5
xargs: yes: terminated by signal 13

I guess this request also interacts with the recent question on whether
'yes' falls into the category of commands that should gain support to
output data with NUL separators rather than newlines.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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