Recursively List all directories and files

后端 未结 7 1790
萌比男神i
萌比男神i 2021-01-30 20:19

I would like to receive the following output.

Suppose the directory structure on the file system is like this:

  -dir1
      -dir2
        -file1
        -fi         


        
7条回答
  •  有刺的猬
    2021-01-30 21:21

    In Linux, a simple

    find . -printf '%y %p\n'
    

    will give you a list of all the contained items, with directories and files mixed. You can save this output to a temporary file, then extract all lines that start with 'd'; those will be the directories. Lines that start with an 'f' are files.

提交回复
热议问题