Get absolute path of files using 'find' command
Solution 1:
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"
Solution 2:
Try something like:
find "$(cd ..; pwd)" -name "filename"