TIMEX
TIMEX

Reputation: 271764

In Linux, how do I write a script that cats all .js files?

In my directory, I want to run the script. The script should take all .js files (and recursively as well), and merge them together into 1 file and spit out that file.

How can I write this script?

Upvotes: 0

Views: 860

Answers (2)

kurumi
kurumi

Reputation: 25599

if you have Ruby(1.9+)

ruby -e 'BEGIN{o=open("out","w")};Dir["**/*.js"].each{|x|o.write(open(x).read()+"\n")};END{o.close()}'

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798626

find somedir/ -name '*.js' -exec cat {} +

Upvotes: 4

Related Questions