summaryrefslogtreecommitdiff
path: root/select_from
diff options
context:
space:
mode:
Diffstat (limited to 'select_from')
-rwxr-xr-xselect_from11
1 files changed, 10 insertions, 1 deletions
diff --git a/select_from b/select_from
index 14fbc9e..7ab40e7 100755
--- a/select_from
+++ b/select_from
@@ -1,7 +1,14 @@
#!/usr/bin/env ruby
+require 'trollop'
require 'zipf'
+opts = Trollop::options do
+ banner "select_from [--invert] -i <file> < <line separated data>"
+ 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]
@@ -11,7 +18,9 @@ f.readlines_strip.each { |line|
i = 0
while line = STDIN.gets
- if accept[i]
+ if accept[i] && !opts[:invert]
+ STDOUT.write line
+ elsif !accept[i] && opts[:invert]
STDOUT.write line
end
i += 1