List files recursively in Linux CLI with path relative to the current directory
Use find:
find . -name \*.txt -print
On systems that use GNU find, like most GNU/Linux distributions, you can leave out the -print.
Try find
. You can look it up exactly in the man page, but it's sorta like this:
find [start directory] -name [what to find]
so for your example
find . -name "*.txt"
should give you what you want.
Use tree
, with -f
(full path) and -i
(no indentation lines):
tree -if --noreport .
tree -if --noreport directory/
You can then use grep
to filter out the ones you want.
If the command is not found, you can install it:
Type following command to install tree command on RHEL/CentOS and Fedora linux:
# yum install tree -y
If you are using Debian/Ubuntu, Mint Linux type following command in your terminal:
$ sudo apt-get install tree -y