Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

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.

share|improve this question

marked as duplicate by Anthon, slm, manatwork, jasonwryan, Sukminder May 24 '13 at 9:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Dup. unix.stackexchange.com/q/76418/6622 You search before asking –  poige May 24 '13 at 4:51

2 Answers 2

up vote 2 down vote accepted

try:

   find . -type f -exec cat {} +
share|improve this answer

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.

share|improve this answer
    
With shopt -s globstar enabled on bash 4+, you can use cat ** instead of the second one. –  evilsoup May 25 '13 at 11:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.