Reputation: 896
Provided that I have the following directory structure:
.
├── 2.txt
├── 3.txt
└── a
└── 1.txt
Now I want to display all contents of all files in this directory, which considered recursion. The possible format displaying like bellow:
a/1.txt:
...the content of 1.txt
2.txt:
...the content of 2.txt
3.txt:
...the content of 3.txt
Upvotes: 0
Views: 38
Reputation: 85620
You can use find
command with -exec
option to run the cat
command on all the files listed, in your case, all the text files,
find . -name "*.txt" -print -exec cat "{}" \;
Run this command from the top folder containing the files 2.txt
and 3.txt
it should display all your file contents with name as you needed.
Upvotes: 2