Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I would add -maxdepth 1 before -name (supposing the file is in the current directory). Without that it will work with files in any subdirectory of pwd, but not with others. Commented May 4, 2020 at 15:01
  • Indeed you are right, the question did specify that the file would be in the current directory. What do you mean "but not with others"?
    – Arj
    Commented May 6, 2020 at 8:47
  • I mean find won't find a file outside the directory tree underneath pwd. E.g., if you try to find . -name ../existingFile, it fails. Commented May 6, 2020 at 13:40
  • Fair enough, yes this'd assume your'e wanting to print the full path of a file in your cwd (as per original question), or anywhere in your cwd tree (not in original question).
    – Arj
    Commented May 12, 2020 at 15:29