如何在linux中列出文件的绝对路径?
我想生成包含完整路径的递归文件列表
I want to generate recursive file listings with full paths
/home/ken/foo/bar
但我可以看到 ls
和 find
只给出相对路径列表
but as far as I can see both ls
and find
only give relative path listings
./foo/bar (from the folder ken)
这似乎是一个明显的要求,但我看不到任何东西在查找
或 ls
手册页。
It seems like an obvious requirement but I can't see anything in the find
or ls
man pages.
如果给出 find
开始的绝对路径,它将打印绝对路径。例如,要在当前目录中找到所有.htaccess文件:
If you give find
an absolute path to start with, it will print absolute paths. For instance, to find all .htaccess files in the current directory:
find `pwd` -name .htaccess
$ p>
到该路径的文件。
find
simply prepends the path it was given to a relative path to the file from that path.
Greg Hewgill 还建议使用 pwd -P
如果要解析当前目录中的符号链接。
Greg Hewgill also suggested using pwd -P
if you want to resolve symlinks in your current directory.