Skip to content

Instantly share code, notes, and snippets.

@gildo
Created December 15, 2010 13:22
Show Gist options
  • Save gildo/741934 to your computer and use it in GitHub Desktop.
Save gildo/741934 to your computer and use it in GitHub Desktop.
Joins files by regex matching
# v0.1 - initial import
#
# Description:
#
# Joins all files matched into one single file
#
# Usage:
#
# ruby jony.rb 2x21
#
# Author: Ermenegildo Fiorito <fiorito.g@gmail.com>
#
# Licese: AGPL (GNU Affero General Public License)[http://www.gnu.org/licenses/agpl-3.0.txt]
#
abort "No args :(, please insert a matcher" if ARGV[0].nil?
(a=Dir["**"].grep(/#{ARGV[0]}/)[0])[-4..-1]=""
puts "joinin' #{a}"
system("cat #{a}* > #{a}")
Dir[a].nil?? "Good!, no errors" : "Ooooops error"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment