Linux recursive directory listing using ls -R command. The -R option passed to the ls command to list subdirectories recursively.
The ls command is used to list files or directories in Linux and other Unix-based operating systems. Just like you navigate in your File explorer or Finder with a GUI, the ls command allows you to list all files or directories in the current directory by default, and further interact with them via the command line.
The dir command displays a list of files and subdirectories in a directory. With the /S option, it recurses subdirectories and lists their contents as well.
The ls (list) command is used to display the names of the files and subdirectories in the current directory.
The -L
option to ls
will accomplish what you want. It dereferences symbolic links.
So your command would be:
ls -LR
You can also accomplish this with
find -follow
The -follow
option directs find to follow symbolic links to directories.
On Mac OS X use
find -L
as -follow
has been deprecated.
How about tree? tree -l
will follow symlinks.
Disclaimer: I wrote this package.
find /dir -type f -follow -print
-type f
means it will display real files (not symlinks)
-follow
means it will follow your directory symlinks
-print
will cause it to display the filenames.
If you want a ls type display, you can do the following
find /dir -type f -follow -print|xargs ls -l
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.
I knew tree
was an appropriate, but I didn't have tree installed. So, I got a pretty close alternate here
find ./ | sed -e 's/[^-][^\/]*\//--/g;s/--/ |-/'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With