6

I was querrying a server using a command like this:

find ./ -type f -name 'filename"

I got many files starting with

.//library 

or

.//user

What do these things mean?

3
  • 2
    Despite what the answers below seem to be claiming, that is not the behavior that POSIX specifies for find; rather, POSIX specifies that find should only add / if the argument doesn't already end in one. (You can see this in the quotation in Thomas Dickey's answer, which he seems to have misinterpreted.) Testing on a version of find I have handy (find (GNU findutils) 4.4.2), I find that it conforms to the POSIX specification; that is, that it does not insert an extra /. Can you post the output of find --version?
    – ruakh
    Oct 15, 2016 at 18:35
  • 1
    Also, can you post the output of find ./ -type f -name library | od? I'm wondering if you have some sort of invisible character between the two /-s.
    – ruakh
    Oct 15, 2016 at 18:36
  • Its a private server and not mine :| Oct 16, 2016 at 2:10

3 Answers 3

7

It doesn't mean much: the pattern that you gave find was ./, and it is simple for find to glue its results onto that path. A double-slash is ignored (treated as a single slash) except that a leading double-slash could have some meaning for some systems. More important, portable programs assume this behavior.

However, you will see this particular behavior only for BSD-derived systems with an old version of find (OSX for example). NetBSD attempted to fix this in their source in 2005; the userland for OSX is older.

Checking "recent" FreeBSD, NetBSD and OpenBSD, none produce this behavior. Linux and Unix (AIX, HPUX, Solaris) likewise do not.

Further reading:

2
  • Also: unix.stackexchange.com/q/256497/117549
    – Jeff Schaller
    Oct 15, 2016 at 17:46
  • 3
    Note that your quotation doesn't actually agree with the behavior the OP is seeing; it specifies that find should only add an extra / if the argument didn't already end with one.
    – ruakh
    Oct 15, 2016 at 18:38
6

The .// means current directory, so .//user in the output indicates file user in the current working directory.

The double // should resolve to a single /, this is true for all systems I've used. Although, POSIX only defines this behavior only for /// (or more), and of course /.

The double // appears because you've used the search path for find as ./, instead of the typical .. Both indicates current working directory, and both are correct. This is find's behavior to append the path in that manner in case of relative paths. Note that, this specific behavior of find is prevalent in only a subset of systems as this answer mentioned, and you one is presumably one of them.

2

.// is the same as ./

Successive slashes beyond the first have no semantic meaning.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .