Printing Data of Every File in a Directory with One Command

A Guide to using cat and Wildcards

Kacper Bąk
2 min readApr 14, 2023

--

Background

Printing the data of every file in a directory can be a useful task in many situations. For example, if you want to quickly review the contents of multiple files in a directory, or if you want to search for specific patterns in multiple files at once, this command can save you a lot of time and effort.

The command I’ll be using for this task is the cat command, which is a standard Unix utility that is used to concatenate and display the contents of files. The cat command takes one or more filenames as arguments, and it outputs the contents of those files to the standard output.

By using a wildcard character (*) as the filename argument to cat, I can tell it to concatenate the contents of all files in the current directory and display them on the screen. This allows us to print the data of every file in a directory with a single command.

Implementation

Let’s now dive into the implementation details of this command. I’ll start by discussing how to use the cat command to concatenate and display the contents of multiple files, and then I’ll show how to use a wildcard character to specify all files in a directory.

--

--