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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityIt 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:
pgsql: Remove trailing slashes from directories in find command
find - find files (POSIX)
The
find
utility shall recursively descend the directory hierarchy from each file specified by path, evaluating a Boolean expression composed of the primaries described in the OPERANDS section for each file encountered. Each path operand shall be evaluated unaltered as it was provided, including all trailing<slash>
characters; all pathnames for other files encountered in the hierarchy shall consist of the concatenation of the current path operand, a<slash>
if the current path operand did not end in one, and the filename relative to the path operand. The relative portion shall contain no dot or dot-dot components, no trailing<slash>
characters, and only single characters between pathname components.
How does Linux handle multiple consecutive path separators (/home////username///file)?
find
should only add an extra /
if the argument didn't already end with one.
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.
.//
is the same as ./
Successive slashes beyond the first have no semantic meaning.
find
; rather, POSIX specifies thatfind
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 offind
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 offind --version
?find ./ -type f -name library | od
? I'm wondering if you have some sort of invisible character between the two/
-s.