tags:

views:

94

answers:

4

This question is based on the answer.

I run at home

find -- ./ Desktop

I understand the command as

  1. find without parameters at the current directory that is home (= /Users/masi/)
  2. find the folder name Desktop at the current directory

How do you read the command?

+2  A: 

The answer to your question in the title is

$ find . -type f

Now, keep in mind that

$ find -- ./ Desktop

will return the files in Desktop twice.

Sinan Ünür
You seem to be right. --- I have though `find` as `find <option> <folder> <filename>`.
Masi
* I mean with filename folderName too.
Masi
+2  A: 

In your example, "--" says to stop looking for further options. Everything else after that is a path, so it finds anything else matching that. And since "./" means "the current directory" it matches everything under the current directory (the Desktop will cause that directory, as well as anything inside it, to be reported twice.)

You probably want something like:

find ./Desktop -type f

Which will find any files inside the ./Desktop directory, that is a file (not directories, symbolic links, etc...)

I know that manpages can be quite technical sometimes, but "man find" will give you a wealth of other options that might help, as well as a few examples that may help with common problems.

Adam Batkin
I now know what my confusion was. `-type` is not an single-letter-option, but instead a many-letter-option that is called `expression` in find's manual of OS X.
Masi
+1  A: 

Well, you can pass multiple directories to search to find:

$ find --help
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
[...]

Note the "[path...]" indicating you can specify multiple paths.

So your example will find all files and directories under ./ (current dir) and under Desktop.

sleske
+1  A: 

I think what you want is:

find ./ -name Desktop
Matt Bridges
Thank you for your answer!
Masi