How to output text file list of contents of a directory?

If you have a folder with huge contents and you want to get a list from them what will you do ? Write down one by one ? 😛

In Linux based distributions you can get a list by a simple command.

How_to_output_text_file_list_of_contents_of_a_directory

Open terminal. Go to your desired folder by cd command.

cd /your/folder/path/

Now if you want to get the list of that folder contents then you can simply get by below command.

ls > file_list.txt

If you want to get a detailed list of that folder contents then use this.

ls -l > file_list.txt

If you want to get a list of that folder contents with hidden ones then use this.

ls -a > file_list.txt

If you want to get a detailed list of that folder contents with hidden ones then use this.

ls -la > file_list.txt

If you want to get a list of that folder and all sub-folder contents then use this.

ls -R > file_list.txt

If you want to get a detailed list of that folder and all sub-folder contents then use this.

ls -lR > file_list.txt

If you want to get a detailed list of that folder and all sub-folder contents with hidden ones then use this.

ls -laR > file_list.txt

Thank You.