zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Zsh Users <zsh-users@zsh.org>
Cc: Ray Andrews <rayandrews@eastlink.ca>
Subject: Re: xargs with zsh function
Date: Wed, 20 Jan 2021 16:27:56 +0000	[thread overview]
Message-ID: <20210120162756.GA5930@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <CAH+w=7YREDgH5WZvK4wpBt8GD21ic6vJBY_ZU6HCpAWjU79KYg@mail.gmail.com>

Bart Schaefer wrote on Sun, Jan 17, 2021 at 19:10:10 -0800:
> What you really want to do is write a nested shell loop that consumes
> N lines, then runs my_function, then does that again until it runs out
> of input; and pipe to that loop.  There are a bunch of ways to do
> that.  E.g.:
> 
> ... | while (true)
>   do
>     set --
>     for i in {1..10}
>     do
>       read $i || break
>     done
>     my_function "$@"
>     [[ $# -eq 10 ]] || break
>   done

If it's fine to call the function with the arguments one at a time, then the
following should do:

    «| xargs -n1 | while IFS= read -r line; do f "${line}"; done»


      parent reply	other threads:[~2021-01-20 16:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-17 23:12 Ray Andrews
2021-01-18  3:10 ` Bart Schaefer
2021-01-18 22:14   ` Ray Andrews
2021-01-18 23:09     ` Bart Schaefer
2021-01-19  5:18       ` Ray Andrews
2021-01-19 14:30         ` Ray Andrews
2021-01-19 17:52           ` Lawrence Velázquez
2021-01-19 20:27             ` Ray Andrews
2021-01-19 21:39               ` Bart Schaefer
2021-01-19 23:48                 ` Ray Andrews
2021-01-20  1:05                 ` Ray Andrews
2021-01-20 18:25                   ` Ray Andrews
2021-01-21  5:52                     ` Bart Schaefer
2021-01-21 19:55                       ` Ray Andrews
2021-01-21 21:50                         ` Bart Schaefer
2021-01-21 23:20                           ` Ray Andrews
2021-01-19 20:31             ` Bart Schaefer
2021-01-19 20:59               ` Ray Andrews
2021-01-20 16:27   ` Daniel Shahaf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210120162756.GA5930@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).