54

I want to cat a file in current folder and all files in all subfolders (and subsubfolders).

Here is my directory structure

$ tree
.
├── f
│   └── foo
└── yo

I want to cat foo and yo.

I've tried this command but did not work:

cat */*

It just cats foo.

slm
  • 363,520
  • 117
  • 767
  • 871
Mohsen
  • 2,495
  • 4
  • 25
  • 29

2 Answers2

62

try:

   find . -type f -exec cat {} +
Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
Raza
  • 4,059
  • 7
  • 28
  • 33
24

cat accepts multiple arguments, so you can:

  cat * */*

to cat everything in the current directory and in all subdirectories. You can also

  cat * */* */*/*

and so on, if you want.

Note, of course, that your shell is translating those '*'s into a list of files then passing that whole list to cat.