LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 08-02-2013, 08:53 AM   #1
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311
Blog Entries: 2

Rep: Reputation: 16
Question Significance of "." with "find" command


I enter in both the following commands and get the same result:
1) find . -print | grep -i foo
2) find -print | grep -i foo

What is the role(significance) of the period? In what situation would there be a difference? Doesn't "." mean hidden?

Even though I was sucessful, I am still curious to understand ".".

Last edited by andrew.comly; 08-02-2013 at 08:55 AM. Reason: append
 
Old 08-02-2013, 09:05 AM   #2
Razaliel
LQ Newbie
 
Registered: Jul 2013
Distribution: Debian testing
Posts: 21

Rep: Reputation: 5
Hi,

When . is put in the beginning of a file name, it makes the file(or directory) hidden indeed. Another meaning of . is the current directory. if you do : ls -a, you can see that there are two particular directories, the . and the .. , the first one . points to the current directory while the second one .. points to the parent directory.

With the command find, you must specify where to look for what you seek. And when you put . after the command find, you tell the command to search in the current directory. It doesn't make a difference if you don't put . because by default it searches in the current directory.
 
1 members found this post helpful.
Old 08-02-2013, 09:07 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
The dot tells find to start looking from the directory you are executing the command from.

You can tell find to start in a different place: find /etc ...... would start looking in /etc

Also have a look at the EXAMPLES section in the find manual page.
 
1 members found this post helpful.
Old 08-02-2013, 10:14 AM   #4
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
I'm from the old school where you had to tell find exactly where you wanted to search, and what you wanted it to do with the results:
Code:
$ find . -name Misc -print
./Misc
$ find . -name Misc -ls
53609606    4 drwxr-xr-x   2 fred    fred        4096 Jul  8 23:54 ./Misc 
$
But these days there are lots of defaults you can take advantage of (note the last variation returns different results):
Code:
$ find -name Misc -print
./Misc
$ find . -name Misc
./Misc
$ find -name Misc
./Misc
$ find Misc
Misc
Misc/tcvol_68
Misc/tcvol_69
$
 
1 members found this post helpful.
Old 08-02-2013, 03:09 PM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
The basic syntax for find is this:

Code:
find <startingdirs> <globalopts> <tests> <actions>
All of the sections can have multiple entries.

If you don't include any starting directories then most versions of find will default to the $PWD, but it's generally better to explicitly set them anyway. At the very least it removes any ambiguity.

(If you aren't aware yet, "." is a hardlink to the current directory. This is built into the file system itself.)


In addition, if you don't include any actions, the default is usually to print the files. But if you have a compound "or" expression you generally have to include your actions explicitly. So again, I think it's better to always include them anyway.

Finally, be aware that I'm mostly writing from experience with gnu find, and I don't know much about other versions.


Here are a couple of good links about using find:
http://mywiki.wooledge.org/UsingFind
http://www.grymoire.com/Unix/Find.html
 
1 members found this post helpful.
  


Reply



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
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 06:41 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:19 PM.

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
Open Source Consulting | Domain Registration