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.)