Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Emulating 'find's print0...
- X-seq: zsh-users 22128
- From: Andreas Perstinger <andipersti@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Emulating 'find's print0...
- Date: Wed, 23 Nov 2016 10:40:19 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=pxhAVYFOkcRfIs5CIrFC0HXi5hRC3UCnXSAuMj4kfro=; b=zdYMihm6/g1vfp8D4OpUV7hA7PnMrm1euIDS1v1XkRwKvl/ADylFtt+41xqSwA4IMY RoNZWdA54WgoEZFPBkMwJ5l6CTPqle3ZbIag55HMf91NYU6SzprJJOcQ7s72hln+8f9S w4BwWZECqf0gdWxJLNLHefHn1HnjQujNkR6Wp6AMMrlaB9M93x0BZoMwzHbYPI1EUDEd 2nXPyrmiY4Xr5QNVppbiRzu0VTcNhdiYX3J67BU3yvmcOhpSo5gDQ7ZzN2kEQrmjxDJp xwE3Ykj/KxnXJylwuxAqcjYdlRIppFB0KdvbEfn46oIFufFzzwH5GHgoxJoz/6+F/KNh Jlvg==
- In-reply-to: <20161123072454.GA4898@solfire>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20161123072454.GA4898@solfire>
On 2016-11-23 08:24, Meino.Cramer@xxxxxx wrote:
cat-ting a list of file like so
cat files.txt | xargs md5sum | sort | .........
fails, if a files name contains blanks.
The tool find circumvent this by using print0
and xargs understands this via -0.
But I dont want to use find in this case, since the
list of files (files.txt) are hand made and a manual
selection of files.
Is there any way to emulate "-print0" efficiently
(that is: without accessing the drive again) ?
You could use the -I option of xargs:
$ cat files.txt
test 1
test2
test with more blanks
$ cat files.txt | xargs -I @ md5sum @ | sort
26ab0db90d72e28ad0ba1e22ee510510 test2
6d7fce9fee471194aa8b5b6e47267f03 test with more blanks
b026324c6904b2a9cb4b88d6d61c81d1 test 1
With "-I replstr", xargs always takes a full line and replaces every
occurence of "replstr" in the argument list of the utility with that line.
The GNU version of xargs also has the -a option which eliminates the cating:
$ xargs -a files.txt -I @ md5sum @ | sort
26ab0db90d72e28ad0ba1e22ee510510 test2
6d7fce9fee471194aa8b5b6e47267f03 test with more blanks
b026324c6904b2a9cb4b88d6d61c81d1 test 1
Bye, Andreas
Messages sorted by:
Reverse Date,
Date,
Thread,
Author