bug-findutils
[Top][All Lists]
Advanced

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

Re: 4.1.7 find directories & exec oddness


From: Bob Proulx
Subject: Re: 4.1.7 find directories & exec oddness
Date: Sat, 15 Jan 2005 16:29:06 -0700
User-agent: Mutt/1.5.6+20040907i

Andreas Metzler wrote:
> find . -name Wills -exec ls -l '{}' \;

Of course it depends upon your shell but the {} is not special in
general.  And since the topic was quoting I could not resist saying
that {} does not need to be quoted.  It is not wrong to quote it, but
it is aslo not needed and I wouldn't quote it in this use.

  find . -name Wills -exec ls -l {} \;

The '{' is a keyword to the shell, like 'if' and 'while'.  But {} is
not a keyword.  Used like {} there is nothing special about it.

I know Andreas is very well familiar with the shell as I have learned
much from his postings.  But I remember learning about this behavior
myself and for the list archive I am going to say a few words about
it.  Perhaps this will be useful to someone else just learning the
shell and will spark them to spend some time to know it better.

  type {
  { is a shell keyword

  type {}
  bash: type: {}: not found

Other interesting behavior originating with csh and migrating to newer
shells is brace expansion.  {foo} is not special.  But if there is a
comma in the string {foo,bar} or a sequence {1..4} or {a..e} then it
is expanded into individual arguments.

  echo {foo,bar}
  foo bar
  echo {1..4}
  1 2 3 4

But there is nothing special without a comma or a sequence that does
not parse as a sequence.

  echo {foo}
  {foo}

That is why find/xargs can use {} as an argument and for another
example GNU arch convention can use {archives} as a filename without
any conflict with brace expansion.

Bob




reply via email to

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