difference between dot f and no dot

dotKer

Member
Joined
Aug 16, 2019
Messages
69
Reaction score
14
Credits
0
dotker@dotker:/var/www/html$ find -type f
./phpversion.php
./another.php
./betong.php
./index1.php
./index.php.save
./index.php.save.1
./index.php
dotker@dotker:/var/www/html$ find . -type f
./phpversion.php
./another.php
./betong.php
./index1.php
./index.php.save
./index.php.save.1
./index.php
The above is coming from shell.
if you look at the below, you can see the difference between the 1st line which has no dot and the 2nd line which has dot.
$ find -type f
$ find . -type f
But the result is same.

What is the meaning of the dot(.) in the 2nd line?
 


The dot . is a relative path that refers to the current working directory.
So the dot in the second find command explicitly tells find to recursively search the current directory.

.. would be the parent directory of the current directory.
../../ would be the grandparent directory of the current directory.... If that makes sense?

And if find is invoked without a path - as per your first example - find will search recursively in the current directory (or dot . ), by default. Which is why the output is exactly the same for both find commands.

And if you are wondering what I mean by . being a relative path - There are two types of paths. Absolute paths and relative paths.
Anything that starts with a forward slash / is an absolute path.
In other words it is a complete, fully specified path from the root of the filesystem.

e.g.
/usr/bin/
/home/username/somedir/somefile.txt
Those are absolute paths.

Anything that doesn't start with a forward slash / is a relative path - because it is relative to the current working directory:
E.g.
./somesubdir/
../somedir/
somedir/somesubdir/somefile.txt
Those are relative paths.
 
Last edited:

Members online


Top