Print a list of "full" relative paths of all the files present in a directory and in its sub-directories
The most straightforward option would be find
:
$ cd /usr/lib; find .
.
./libxcb-icccm.so.4.0.0
./libbz2.so.1.0.6
./libdca.so.0
./libxcb-composite.so
./libyajl.so
./libswscale.so
./libxvidcore.so.4.3
./libjasper.so.1
./libdrm_intel.so.1
...
It has various tests for filtering such as:
-
-type
to filter based on type (regular filef
, directoryd
, etc.) -
-mindepth
and-maxdepth
to set the depths to whichfind
should search (not really tests as such) -
-name
and-path
to filter based on filename and path, supporting wildcards. - and a lot of other tests, for permissions, ownership, times, etc.
It offers a variety of output formats, using the -printf
option.
Depending on the shell and the options enabled, you can also use globbing for this purpose. For example, in bash
:
$ shopt -s globstar; printf "%s\n" **
accountsservice
accountsservice/accounts-daemon
aisleriot
aisleriot/ar-cards-renderer
aisleriot/guile
aisleriot/guile/2.0
aisleriot/guile/2.0/accordion.go
aisleriot/guile/2.0/agnes.go
aisleriot/guile/2.0/aisleriot
aisleriot/guile/2.0/aisleriot/api.go
...
And in zsh
:
$ printf "%s\n" **/*
accountsservice
accountsservice/accounts-daemon
aisleriot
aisleriot/ar-cards-renderer
aisleriot/guile
aisleriot/guile/2.0
aisleriot/guile/2.0/accordion.go
aisleriot/guile/2.0/agnes.go
aisleriot/guile/2.0/aisleriot
aisleriot/guile/2.0/aisleriot/api.go
...