Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Emulating 'find's print0...
- X-seq: zsh-users 22129
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Meino.Cramer@xxxxxx
- Subject: Re: Emulating 'find's print0...
- Date: Wed, 23 Nov 2016 17:39:28 +0100
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=FKjQLo70mmW/FLscw/fiI2dCZicAKnWTcqSzV9fBZDU=; b=utdzWYB4Xfg4gig3P2yrPbiQS9GErp4XlsppPeCDGFsrNEHbXz1/mySA8daQzD/0/I e5+pP8MJOQYK8wnffjbzHXIQfX24kd9ncoNoio+NZlhT3JgoVNFCFAg3SdsDSn5XDunn +tDuGgDKUUnj5fQyOPKnLNrCDfky5HDNwxiM9wpRyX/3yklCJa/ztXgXzhZE2TTSXQCu gADTZWFlUnRtxgIIrRBomaRh9Evq28VQLDwc3wRj6vOMVctYhoqk9KvkymrjoJcrgQ0H qQbJE2FhjayMdzT8bJdwQZl1Yyb1v76FZ9N2Fkxiy7KQ85t0qx2I5pINNvUYdHi/AbDU aMiw==
- 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 Wed, Nov 23, 2016 at 8:24 AM, <Meino.Cramer@xxxxxx> wrote:
> Hi,
>
> 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) ?
If you use a reasonable version of xargs, you can specify -d\\n to
only split on newlines. (POSIX xargs doesn't have it, but then again,
POSIX xargs is almost impossible to use safely).
Some examples:
% print -l "one line" "another line" | xargs printf %s\\n
one
line
another
line
% print -l "one'line" "another line" | xargs printf %s\\n
xargs: unmatched single quote; by default quotes are special to xargs
unless you use the -0 option
% print -l "one'line" "another line" | xargs -d\\n printf %s\\n
one'line
another line
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author