Quickly Find Out Contents Of Directories And Subdirectories Using Linux Terminal

Linux command line / Terminal offers a quick and simple way to do most things. Let’s say that if we want to view contents of a directory and all the sub directories within it quickly all in one go, here is how to do it :

1. Open Terminal and type the path of the directory whose contents (along with the contents of subdirectories and their subdirectories and so on )  after ls command and the R switch so that it looks like this :

ls -R pathofdirectory

In the example shown below, there is a directory named colors in the home folder (/home/avp/colors). Within this directory are sub directories named blue, green and red. Within each of these sub directories are files named bluecolor.txt, greencolor.txt and redcolor.txt

All of this is simply found out by typing :

ls -R /home/avp/colors/

List directory contents recursively in Linux

This will quickly list everything within that directory and the directories within it and so on. Commonly it is known as recursive listing and is pretty handy when trying to search for a specific file or a directory.

To understand how powerful Linux commands can be, do take a look at our Linux command line basics turorials.


Comments are closed.