unixcat

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


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?


Solution

  • 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*