我如何吐出一行递归路径的平面列表?

例如,我只想要一个文件的完整路径的平面列表:

/home/dreftymac/.
/home/dreftymac/foo.txt
/home/dreftymac/bar.txt
/home/dreftymac/stackoverflow
/home/dreftymac/stackoverflow/alpha.txt
/home/dreftymac/stackoverflow/bravo.txt
/home/dreftymac/stackoverflow/charlie.txt

ls -a1几乎满足了我的需要,但我不想要路径片段,我想要完整的路径。


当前回答

试试下面的简单方法:

find "$PWD"

其他回答

除了ls,不使用任何外部命令:

ls -R1 /path | 
  while read l; do case $l in *:) d=${l%:};; "") d=;; *) echo "$d/$l";; esac; done

找到/就行了

一长串的答案。 这很有帮助,最后,我创建了我自己的,我正在寻找:

列出目录及其子目录下的所有文件。

find "$PWD" -type f

列出目录及其子目录下的所有目录。

find "$PWD" -type d

列出目录及其子目录下的所有目录和文件。

find "$PWD"

ls -lR是你要找的,至少我是。干杯

我知道文件名,但也想知道目录。

find $PWD | fgrep filename

在Mac OS 10.12.1中完美运行