help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] how to understand the xargs


From: Greg Wooledge
Subject: Re: [Help-bash] how to understand the xargs
Date: Wed, 28 Dec 2011 09:40:55 -0500
User-agent: Mutt/1.4.2.3i

On Wed, Dec 28, 2011 at 12:12:52AM -0600, Dan Douglas wrote:
> On Tuesday, December 27, 2011 12:11:59 AM lina wrote:
> > ls . | xargs -i -t cp ./{} {}.bak

> Always use read -a (-A in ksh and zsh), read in a loop, or mapfile. They're 
> totally invaluable.

As wonderful as arrays are, for this particular task, a simple glob is
the way to go.  For processing all the files in a single directory
(non-recursively), globs are almost *always* preferred.

For recursive processing, either use find . -exec, or
find . -print0 | while read -d ''.  (The latter requires a system with
a common but nonstandard extension to the find command.)



reply via email to

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