How to display contents of all files under a directory on the screen using unix commands

bvb picture bvb · Jan 22, 2014 · Viewed 65.8k times · Source

Using cat command as follows we can display content of multiple files on screen

cat file1 file2 file3

But in a directory if there are more than 20 files and I want content of all those files to be displayed on the screen without using the cat command as above by mentioning the names of all files.

How can I do this?

Answer

Munim picture Munim · Jan 22, 2014

You can use the * character to match all the files in your current directory.
cat * will display the content of all the files.
If you want to display only files with .txt extension, you can use cat *.txt, or if you want to display all the files whose filenames start with "file" like your example, you can use cat file*