LinuxQuestions.org
Review your favorite Linux distribution.
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-27-2012, 07:18 AM   #1
.product
LQ Newbie
 
Registered: Dec 2012
Location: India
Distribution: Ubuntu
Posts: 8

Rep: Reputation: Disabled
Find question ? How to use wild cards with arguments ?


Hi,
There exist ~/docs/office/report.txt
why does following command fails to get it.
~>find ./ -name report*

where as if i give the full name report.txt it works ! Any ideas Why ?

Thanks,
 
Old 12-27-2012, 07:27 AM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,974

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
Hi,

on my system it works
Code:
markus@samsung:~$ find ./ -name report*
./test/report.txt
which shell and which version of find are you using?

btw: you should try "report*" instead.

Markus
 
Old 12-27-2012, 07:34 AM   #3
.product
LQ Newbie
 
Registered: Dec 2012
Location: India
Distribution: Ubuntu
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thanks for the quick response using "report*" worked !
I am noob and have few more questions.
why "" works ?
I am using tcsh how do i find the version of it ?
 
Old 12-27-2012, 07:36 AM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,974

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
Well, I'm using Bash, but I also (sometimes) had issues when using wildcard without "", I don't know why.

If you want to know the version of tcsh use the command
Code:
tcsh --version
which works for most commandlineprgrams.

Markus

Last edited by markush; 12-27-2012 at 07:38 AM.
 
Old 12-27-2012, 07:46 AM   #5
.product
LQ Newbie
 
Registered: Dec 2012
Location: India
Distribution: Ubuntu
Posts: 8

Original Poster
Rep: Reputation: Disabled
%> man find
SYNOPSIS
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]

Could it be that last option is expression and "" might be required to evaluate input as string ?

Thanks,
 
Old 12-27-2012, 08:06 AM   #6
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,974

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
No, I don't think so. The word expression in the find manpage is used with several meanings, don't be confused. I would recommend that you read the manpage for find and afterwards read here http://rute.2038bug.com/node7.html.g...00000000000000 and here http://content.hccfl.edu/pollock/unix/findcmd.htm

Markus
 
1 members found this post helpful.
Old 12-27-2012, 03:43 PM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,619

Rep: Reputation: 676Reputation: 676Reputation: 676Reputation: 676Reputation: 676Reputation: 676
Quote:
Originally Posted by .product View Post
Hi,
There exist ~/docs/office/report.txt
why does following command fails to get it.
~>find ./ -name report*

where as if i give the full name report.txt it works !
When an argument to a command uses a shell meta-character, like '*', you should always quote that argument to protect it from being evaluated by the shell. In this case, the shell will try to expand that argument in the current directory, and if anything matches then the result of that expansion is what gets passed to find. If the current directory happened to contain a file named "reporters", then the command that is actually executed would be
Code:
find ./ -name reporters
and that is not going to match a file named "report.txt".

Now if someone tries your command line when there is not any matching file in the current directory, then the argument gets passed unaltered and find does what was expected.

Incidentally, if the pattern happens to match more and one name in the current directory, then all of those names will be included in the find command, and the result is the rather confusing error message, "find: paths must precede expression: ...".
 
2 members found this post helpful.
Old 12-28-2012, 04:20 AM   #8
.product
LQ Newbie
 
Registered: Dec 2012
Location: India
Distribution: Ubuntu
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thanks folks. Very helpful
 
  


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
rename command and wild cards dkrysak Linux - Newbie 8 08-27-2009 03:06 PM
Need information about wild cards shridhar005 Linux - Newbie 1 08-27-2008 02:41 PM
how to do * wild cards in python donnied Programming 6 08-19-2008 10:26 PM
Wild Cards using the find command -- grrr hpladd Linux - Newbie 9 07-14-2005 06:18 PM
More Players Supporting Wild-Cards? chime Linux - General 0 12-01-2004 11:21 AM


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

Main Menu
Advertisement
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