#!/usr/bin/ruby require 'tempfile' paths = `find -name \"*.rb\"` paths.each do |path| header = `cat gplheader` excludes = ["./gplh.rb"] pth = path.chomp if not excludes.include?(pth) Tempfile.open File.basename(path.chomp) do |tempfile| # prepend data to tempfile tempfile << header File.open(path.chomp, 'r+') do |file| # append original data to tempfile tempfile << file.read # reset file positions file.pos = tempfile.pos = 0 # copy all data back to original file file << tempfile.read p "Added header to: "+file.path end end end end p "Done."