Question: I always have to submit the source codes in my printed assignment report. **I have to copy and paste my course codes** into the document and I find that it is an annoying task.

I want to solve this **"copy and paste"** problem. Therefore I did it with `cat` like that but it only works in the current directory. I hope it can display the file contents recursively.

```
ls -R *.java | xargs cat >> all_course.txt

```

Answer: 
You can use `find` ([man page](http://linux.die.net/man/1/find)) to accomplish this:

```
find -name "*.java" -exec cat {} \;

```

You can also add a `-print` before the `-exec` to print the file name before each cat operation
```
find . -name "*.java" -exec cat {} \;

```