Get absolute path of files using 'find' command
You can use bash
's Tilde Expansion to get the absolute path of the current working directory, this way find
prints the absolute path for the results as well:
find ~+ -type f -name "filename"
If executed in ~/Desktop
, this is expanded to
find /home/yourusername/Desktop -type f -name "filename"
and prints results like:
/home/yourusername/Desktop/filename
If you want to use this approach with the current working directory’s parent directory you need to cd
before calling find
:
cd .. && find ~+ -type f -name "filename"
Try something like:
find "$(cd ..; pwd)" -name "filename"
Try using the -exec
option of find
:
find .. -name "filename" -exec readlink -f {} \;
Note: readlink
prints the value of a symbolic link or canonical file name.