如何检索给定相对路径的绝对路径

问题描述:

在给定相对路径的情况下,是否有一条命令可以检索绝对路径?

Is there a command to retrieve the absolute path given the relative path?

例如,我希望$ line在dir ./etc/

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

使用:

find $(pwd)/ -type f

获取所有文件或

echo $(pwd)/$line

显示完整路径(如果相对路径很重要)

to display full path (if relative path matters to)