I would like to display several files one after another in a terminal, for instance, all the files of type .java in the current folder. Does anyone know how to do that by a line of shell? I guess probably we need to use cat and a variable…
Also, if possible, I would like to add the name of the files… For instance, the final layout in the terminal would be
p1.java
...
contents of p1.java
...
p2.java
...
contents of p2.java
...
Does anyone know how to do it? Thank you very much!
Could be as simple as:
If you want to display the filename before each listing, just use a loop:
Just to enrich this answer a little bit: If you browse source code in your terminal regularly, you can get the content syntax highlighted as well via pygments. I use the following tiny function in my bashrc.
Here’s an example screenshot: