Recursively list all files in a directory including files in symlink directories

后端 未结 8 905
甜味超标
甜味超标 2020-12-07 07:46

Suppose I have a directory /dir inside which there are 3 symlinks to other directories /dir/dir11, /dir/dir12, and /dir/dir13

8条回答
  •  执笔经年
    2020-12-07 08:34

    Using ls:

      ls -LR
    

    from 'man ls':

       -L, --dereference
              when showing file information for a symbolic link, show informa‐
              tion  for  the file the link references rather than for the link
              itself
    

    Or, using find:

    find -L .
    

    From the find manpage:

    -L     Follow symbolic links.
    

    If you find you want to only follow a few symbolic links (like maybe just the toplevel ones you mentioned), you should look at the -H option, which only follows symlinks that you pass to it on the commandline.

提交回复
热议问题