How can I find the directory for a file?
In my Unix shell, I know how to use the ls command, but it shows just the name of the file. I need the path too. How do I get it?
3 Answers
echo "$PWD/filename" will print the name of the filename, including the path.
A quick search led me to this:
find / -name "filename" -type f -printor
locate filename 1 In Linux you can use readlink -f; on BSDs realpath might work.