Is there a command to retrieve the absolute path given the relative path?
For example I want $line to contain the absolute path of each file in dir ./etc/
find ./ -type f | while read line; do
echo $line
done
Try realpath
.
~ $ sudo apt-get install realpath # may already be installed
~ $ realpath .bashrc
/home/username/.bashrc
To avoid expanding symlinks, use realpath -s
.
The answer comes from "bash/fish command to print absolute path to a file".