bash – How to get a list with absolute paths of all directories and files in them recursively?

Question:

The / home / user / files directory contains many directories and files. Each directory, including the one above, contains files. It is necessary from the above directory to get a list of all directories and subdirectories nested in them, as well as files. Get as a list:

/path/to/file.ext

As I understand it, the line is fine for me:

find . -name "*" -type f -exec ls -l {} \;

But it outputs the result to "ls -l", and it fails to parse it.

Answer:

to get a list of files with absolute paths, specify the absolute path to the given directory:

$ find /абсолютный/путь/к/каталогу -type f

if this is the current directory, you can use, for example, the value of the $PWD environment variable:

$ find $PWD -type f

if you need not only files (as indicated in the command you give), but also directories (as indicated in the title of the question), then add -o -type d to the command:

$ find /абсолютный/путь/к/каталогу -type f -o -type d

in general, objects in a filesystem are not limited to just (regular) files ( f ) and directories ( d ). there are also block ( b ) and symbolic ( c ) devices, named pipes ( p ), sockets ( s ), and symbolic links ( l ). see man find description of the -type option.

if you remove the mention of this option altogether, then all types of objects will be displayed:

$ find /путь
Scroll to Top