I use the find-command for searching in large and nested directory-structures.

In the result-output is sometimes a double-slash ( // ) included.

Example (after "Downloads"):

#> find ~/Downloads/ -iregex ".*some.*"

I first thought it would mark the current working-directory. But that isn't the case.

What's the meaning of this double-slash?

Usually I copy the result into the clipboard, change to the finder. Then "shift" + "command" + "g" and pasting the path (until the file) into the box. So that the containing directory is opened.

Works fine. But the double-slash I have to remove manually.

Therefore: How can I avoid it?

  • 3
    Note that you don't have to remove the double slash. A double slash is only special at the beginning of a path, and only if it's exactly two slashes. Multiple slashes in the middle or at the end or any number of slashes than exactly two at the beginning are exactly equivalent to one slash. That's guaranteed by the POSIX/SUS specification. Commented Aug 14, 2016 at 13:38

2 Answers 2


find is rather literal. When you tell it to search within "~/Downloads/", it uses that (including the trailing slash) as the prefix for whatever it finds. Since there's an unnecessary and irrelevant slash at the end of the path you gave it, you wind up with an unnecessary and irrelevant extra slash in the output.

Solution: remove the trailing "/" from the search directory:

#> find ~/Downloads/ -iregex ".*some.*"
#> find ~/Downloads -iregex ".*some.*"

What's the meaning of this double-slash?

Means you're using strange old BSD find.

How can I avoid it?

You can indeed omit the trailing slash in your original command, but since it's added automatically via tab completion (which you should definitely make as much use of as possible), & since the trailing slash is actually used in myriad places elsewhere to be sure you're dealing with a directory and not a filename, omitting it is counterintuitive & silly.

Instead, I suggest doing one of these other things:

a) Make a wrapper for find that pipes to sed: | sed 's@//@/@'

b) Install GNU's findutils with 'brew install findutils' and then either use 'gfind' directly, alias 'find' to 'gfind', or add /usr/local/opt/findutils/libexec/gnubin to your path (which also adds GNU findutils' 'locate', 'updatedb', & 'xargs').

c) Switch to a proper GNU/Linux OS that wouldn't have had this problem (& a thousand others) in the first place. :p

  • 1
    Just add set mark-directories off to your .inputrc and you're good to go. From one of those old BSD guys.
    – fd0
    Commented Sep 23, 2016 at 19:16
  • @fd0 then one wouldn't be able to distinguish between dirs and files with the same name; it's BSD's find that's a little crufty here, not bash or readline Commented Sep 23, 2016 at 22:05

You must log in to answer this question.

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