zsh-users
 help / color / mirror / code / Atom feed
* recursive globbing, filename spaces and xargs
@ 2005-01-17 15:14 William Scott
  2005-01-18  0:49 ` Bart Schaefer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: William Scott @ 2005-01-17 15:14 UTC (permalink / raw)
  To: zsh-users


Hi:

One of the things that I haven't been able to figure
out is how to deal with the error one gets when using

ls **/*

on a well-populated directory with lots of subdirectories.

zsh: argument list too long

If I do this when there are no filename spaces, it works:

echo **/*  | xargs ls

but if there are spaces, it fails, and I can't seem to figure
out how to quote or escape the spaces.

Any suggestions, or should I stick to find?

Thanks.

Bill Scott



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: recursive globbing, filename spaces and xargs
  2005-01-17 15:14 recursive globbing, filename spaces and xargs William Scott
@ 2005-01-18  0:49 ` Bart Schaefer
  2005-01-18  0:51 ` Christian Schneider
  2005-01-18  1:15 ` Philippe Troin
  2 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2005-01-18  0:49 UTC (permalink / raw)
  To: William Scott, zsh-users

On Jan 17,  7:14am, William Scott wrote:
} 
} ls **/*
} 
} zsh: argument list too long

Depending on your version of zsh, you may find that a function called
"zargs" comes with the distribution.  It's designed precisely for this.
Look in "man zshcontrib" or the function definition file itself for
documentation.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: recursive globbing, filename spaces and xargs
  2005-01-17 15:14 recursive globbing, filename spaces and xargs William Scott
  2005-01-18  0:49 ` Bart Schaefer
@ 2005-01-18  0:51 ` Christian Schneider
  2005-01-18  1:15 ` Philippe Troin
  2 siblings, 0 replies; 6+ messages in thread
From: Christian Schneider @ 2005-01-18  0:51 UTC (permalink / raw)
  To: zsh-users

* William Scott <wgscott@chemistry.ucsc.edu> typed:
> One of the things that I haven't been able to figure
> out is how to deal with the error one gets when using
> 
> ls **/*
> 
> on a well-populated directory with lots of subdirectories.
> 
> zsh: argument list too long
> 
> If I do this when there are no filename spaces, it works:
> 
> echo **/*  | xargs ls
> 
> but if there are spaces, it fails, and I can't seem to figure
> out how to quote or escape the spaces.

You can use `zargs' to do this:
 $ autoload -U zargs
 $ zargs -- ls **/*
Read ``less ${^fpath}/zargs(N)'' for more details. HTH.
-- 
http://www.strcat.de/zsh/#features [*] Christian 'strcat' Schneider
http://www.strcat.de/zsh/#tipps    [*] Email.......: strcat@gmx.net
http://www.strcat.de/zsh/#modex    [*] GPG-ID......:       47E322CE
http://www.strcat.de/zsh/#links    [*] [zsh - the Z shell]


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: recursive globbing, filename spaces and xargs
  2005-01-17 15:14 recursive globbing, filename spaces and xargs William Scott
  2005-01-18  0:49 ` Bart Schaefer
  2005-01-18  0:51 ` Christian Schneider
@ 2005-01-18  1:15 ` Philippe Troin
  2005-01-18  2:06   ` William Scott
  2005-01-18  9:05   ` Stephane Chazelas
  2 siblings, 2 replies; 6+ messages in thread
From: Philippe Troin @ 2005-01-18  1:15 UTC (permalink / raw)
  To: William Scott; +Cc: zsh-users

William Scott <wgscott@chemistry.ucsc.edu> writes:

> Hi:
> 
> One of the things that I haven't been able to figure
> out is how to deal with the error one gets when using
> 
> ls **/*
> 
> on a well-populated directory with lots of subdirectories.
> 
> zsh: argument list too long
> 
> If I do this when there are no filename spaces, it works:
> 
> echo **/*  | xargs ls
> 
> but if there are spaces, it fails, and I can't seem to figure
> out how to quote or escape the spaces.
> 
> Any suggestions, or should I stick to find?

print -N **/* | xargs -0 ....

Phil.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: recursive globbing, filename spaces and xargs
  2005-01-18  1:15 ` Philippe Troin
@ 2005-01-18  2:06   ` William Scott
  2005-01-18  9:05   ` Stephane Chazelas
  1 sibling, 0 replies; 6+ messages in thread
From: William Scott @ 2005-01-18  2:06 UTC (permalink / raw)
  To: Philippe Troin; +Cc: William Scott, zsh-users


That works.  Many thanks.

> print -N **/* | xargs -0 ....
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: recursive globbing, filename spaces and xargs
  2005-01-18  1:15 ` Philippe Troin
  2005-01-18  2:06   ` William Scott
@ 2005-01-18  9:05   ` Stephane Chazelas
  1 sibling, 0 replies; 6+ messages in thread
From: Stephane Chazelas @ 2005-01-18  9:05 UTC (permalink / raw)
  To: Philippe Troin; +Cc: William Scott, zsh-users

On Mon, Jan 17, 2005 at 05:15:49PM -0800, Philippe Troin wrote:
[...]
> > echo **/*  | xargs ls
> > 
> > but if there are spaces, it fails, and I can't seem to figure
> > out how to quote or escape the spaces.
> > 
> > Any suggestions, or should I stick to find?
> 
> print -N **/* | xargs -0 ....

That would still fail for filenames with backslashes or starting
with "-".

print -rN -- **/* | xargs -r0 ls -d --

Or
autoload -U zargs
zargs ./**/* -- ls -d

-- 
Stéphane


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-01-18  9:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-17 15:14 recursive globbing, filename spaces and xargs William Scott
2005-01-18  0:49 ` Bart Schaefer
2005-01-18  0:51 ` Christian Schneider
2005-01-18  1:15 ` Philippe Troin
2005-01-18  2:06   ` William Scott
2005-01-18  9:05   ` Stephane Chazelas

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).