Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: xargs with zsh function
- X-seq: zsh-users 26403
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Cc: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: xargs with zsh function
- Date: Wed, 20 Jan 2021 16:27:56 +0000
- Archived-at: <https://zsh.org/users/26403>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2021-01/20210120162756.GA5930%40tarpaulin.shahaf.local2>
- In-reply-to: <CAH+w=7YREDgH5WZvK4wpBt8GD21ic6vJBY_ZU6HCpAWjU79KYg@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <eee04aa4-394f-9e4b-1637-538059745b5c@eastlink.ca> <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»
Messages sorted by:
Reverse Date,
Date,
Thread,
Author