LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Find and special file names (https://www.linuxquestions.org/questions/linux-newbie-8/find-and-special-file-names-269685/)

CritterZ 12-23-2004 03:56 PM

Find and special file names
 
Howdy y'all !!

Hope everyone is geared up for an awsome holz !

Am pulling my hair out on a problem with the find util while running a bash script in Cygwin.

given the following 2 files in a directory named as such:

nofoo.txt
foo[bar].txt

doing...

find . -max-depth 1 -type f -name *.txt

results only in the first file being found. I'm sure it has to do with the second file having brackets in it, and that fnmatch is wigging out on it.... how do I work around this?

Thanks HUGE !

CritterZ 12-23-2004 04:04 PM

Aha !
 
Fingered it out m'self. {pat} {pat} :D

find . -maxdepth 1 -type f -regex .*.txt$

.
.
.

Now..... could somone explain why the orginal metod fails? Is that the intended functionality?

Demonbane 12-23-2004 09:49 PM

You need to add double quotes to the wildcard pattern, eg

find . -max-depth 1 -type f -name "*.txt"

otherwise the asterisk gets expanded by the shell before the command executes.


All times are GMT -5. The time now is 09:18 PM.