#!/usr/bin/env ruby require 'trollop' require 'zipf' opts = Trollop::options do banner "select_from [--invert] -i < " opt :index, "Line numbers to output.", :required => true opt :invert, "Invert selection.", :type => :bool, :short => '-j', :default => false end accept = {} f = ReadFile.new ARGV[0] f.readlines_strip.each { |line| accept[line.strip.to_i] = true } i = 0 while line = STDIN.gets if accept[i] && !opts[:invert] STDOUT.write line elsif !accept[i] && opts[:invert] STDOUT.write line end i += 1 end