#!/usr/bin/env ruby require 'optparse' require 'isna' options = {} OptionParser.new do |opts| opts.banner = "Usage: #{$0} [OPTIONS]" opts.on('-r', '--remove [FILEPATH]', 'File with entries that will be removed.') do |value| options[:remove] = value end end.parse! required_options = [:remove] required_options.each do |option| unless options[option] $stderr.puts "Can not run #{option.to_s} was not given." exit 1 end end unless File.exist?(options[:remove]) $stderr.puts "File #{options[:remove]} does not exist." exit 1 end source_list = [] remove_list = [] File.read(options[:remove]).each_line do |line| remove_list << line.chomp end STDIN.each_line do |line| source_list << line.chomp end (source_list - remove_list).each do |item| puts item end