Find path of a file only given the name

Asked

Viewed 81 times

1

I am trying to find the path of a file just knowing its name. I have tried several ways including pwd but it’s no use to me. There will be some way to do it ? (I have assurance that this is the only file with that name , so there are no different paths)

  • What file do you want to get the address from? has some code started?

  • You can use the features of your Operating System. For example, to find a file named "FOO.BAR" in Windows (search inside the current directory): dir /s /a /b foo.bar; in Un*x (search from the root): find / -iname foo.bar.

  • You need to be more specific with your question: 1) do you want to find a file in a directory tree? - 2) Do you want to know the complete path of a given file ? - 3) Do you want to know the base directory of a given file?

1 answer

0

If you are in a POSIX system you can use the ntfw function().

Or write a recursive function that scans a directory for the file.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.