Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-02-2013, 08:53 AM   #1
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0
Posts: 269
Blog Entries: 2

Rep: Reputation: Disabled
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
LQ Newbie
Registered: Jul 2013
Distribution: Debian testing
Posts: 21

Rep: Reputation: 5

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
LQ Veteran
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
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
Senior Member
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian
Posts: 2,165

Rep: Reputation: 334Reputation: 334Reputation: 334Reputation: 334
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:
$ find . -name Misc -print
$ 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):
$ find -name Misc -print
$ find . -name Misc
$ find -name Misc
$ find Misc
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: Debian sid + kde 3.5 & 4.4
Posts: 6,823

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

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:
1 members found this post helpful.


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
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

All times are GMT -5. The time now is 04:17 AM.

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