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.
Use find: find . -name \*.txt -print On systems that use GNU find, like most GNU/Linux distributions, you can leave out the -print.
Use the -1 option (note this is a “one” digit, not a lowercase letter “L”), like this: ls -1a First, though, make sure your ls supports -1. GNU coreutils (installed on standard Linux systems) and Solaris do; but if in doubt, use man ls or ls –help or check the documentation. E.g.: $ man ls … Read more
If you give find an absolute path to start with, it will print absolute paths. For instance, to find all .htaccess files in the current directory: find “$(pwd)” -name .htaccess or if your shell expands $PWD to the current directory: find “$PWD” -name .htaccess find simply prepends the path it was given to a relative … Read more
this is one: ls -l . | egrep -c ‘^-‘ Note: ls -1 | wc -l Which means: ls: list files in dir -1: (that’s a ONE) only one entry per line. Change it to -1a if you want hidden files too |: pipe output onto… wc: “wordcount” -l: count lines.
Use find: find . find /home/dreftymac If you want files only (omit directories, devices, etc): find . -type f find /home/dreftymac -type f
*/ is a pattern that matches all of the subdirectories in the current directory (* would match all files and subdirectories; the / restricts it to directories). Similarly, to list all subdirectories under /home/alice/Documents, use ls -d /home/alice/Documents/*/