BASH: matching a directory in the middle of a path
25 pts.
0
Q:
BASH: matching a directory in the middle of a path
How can I do this in bash?
find . -name '*\!{*}*' -ls

Cf. UNIX Power Tools, page 175.
This works in tcsh, but no in bash.
In bash I get this message:
ff CH18
find: paths must precede expression
Usage: find [-H] [-L] [-P] [expression]
ASKED: Jun 6 2009  2:39 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
340 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
I think your version of bash may be just too old. I tried this command in version 3.2-23 and it worked without error.
Last Answered: Jun 9 2009  3:39 PM GMT by Djeepp   340 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Landocalvinian   25 pts.  |   Jun 9 2009  8:54PM GMT

Thank you, Djeepp.

I downloaded bash 4.0 and now I get data, but it is way more than I expect.
Basically a find . -print.

???/

 

Petkoa   1005 pts.  |   Jun 10 2009  5:11PM GMT

Hi,

this message basically means that some parameter expansion happened in the shell and expanded parameter to -name confused find.

In this example I would backslah-escape the curly brackets… though tested it in bash 3.0, and it works in your original syntax…

What was you initial bash version?

BR,

Petko

 

Landocalvinian   25 pts.  |   Jun 12 2009  5:30PM GMT

Hello, Petkoa

Here’s the answer to your version question:

GNU bash, version 3.2.13(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

 

Petkoa   1005 pts.  |   Jun 15 2009  4:44PM GMT

Well, then - it works with 3.0 and 4.0 - there should be no reasons not to work under 3.2 (at least I can’t recall any changes in quoting/escaping that took place after 3.0 (and were reversed in 4.0)… The find expression may not work in double-quotes (though, in my environment it works), but should work in single-quiotes, as you posted it. I’m really puzzled.

BR,

Petko

 
0