LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-23-2004, 03:56 PM   #1
CritterZ
LQ Newbie
 
Registered: Nov 2004
Posts: 4

Rep: Reputation: 0
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 !
 
Old 12-23-2004, 04:04 PM   #2
CritterZ
LQ Newbie
 
Registered: Nov 2004
Posts: 4

Original Poster
Rep: Reputation: 0
Aha !

Fingered it out m'self. {pat} {pat}

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

.
.
.

Now..... could somone explain why the orginal metod fails? Is that the intended functionality?
 
Old 12-23-2004, 09:49 PM   #3
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with special syntax on the 'find' command Seventh Linux - General 4 01-20-2005 01:16 PM
How to find out my scsi dev names? Thaidog Linux - Newbie 3 08-31-2004 04:18 AM
how do I find out device names for mounting kkempter Linux - General 1 12-11-2003 03:35 PM
how can i find all include special word in a dir henryluo Linux - General 4 11-12-2003 10:56 AM
how to find volume names for CD? sanglih Linux - Software 0 06-24-2002 11:57 AM


All times are GMT -5. The time now is 06:59 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration