#!/usr/bin/env ruby require 'optimist' require 'zipf' opts = Optimist::options do banner "sample --index [--shuffle] [--file ]" opt :file, "Input file.", :type => :string, :default => '-' opt :index, "Index file.", :type => :string, :required => true end input = ReadFile.readlines_strip opts[:file] index = ReadFile.readlines_strip(opts[:index]).map{ |i| i.to_i } index.each { |i| puts input[i] }