List all files and directories recursively but do not include full path
Posted on August 10th, 2008 by linux
ls -R will list all files recursively. The output of such a command will produce a output containing not only a files but also full path the the each file or directory. One way to clean this output is to use grep and invert selection with -v option. Each path from ls -R command contains “:” symbol and we can use grep command to invert selection based on “:” :
ls -R | grep -v :
this will list all files and directories only. However output will still produce a empty lines. This can be again removed by -v where we invert selection and remove all empty lines ^$
ls -R | grep -v | grep -v ^$
Filed under: Administration, Commands, Linux