How do I get a list of all directories and files with absolute paths each line?

ls -R /,
i get every file and directory listed that exists, but not with the full file path.

What do I need to write on the command line in order to get a list in such a format, that every line contains an absolute path.

Asked By: Abdul Al Hazred


You can get the files with full path with this command:

find / -type f

or list files from the current directory down:

find $(pwd) -type f
Answered By: Romeo Ninov

There are two commands you can use along with ls if you intend just for the files in a particular directory.

  1. realpath
  2. readlink

I can’t show you realpath output as i don’t have it in my system.

You can make readlink to do that for you.

ls | xargs -n 1 readlink -f

WARNING: you may not get the abs path for the soft links as that will be converted to the files which are the linked to.

Answered By: bluefoggy
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.