diff options
author | Patrick Simianer <p@simianer.de> | 2015-01-07 18:47:50 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2015-01-07 18:47:50 +0100 |
commit | cf0bf046e51a4a76315b8c964fabc8e641eb91fe (patch) | |
tree | c2746bc11a2a33007636f98c96bded350e264f40 | |
parent | e0b634754d1bef33dc8e72509c6990cccc32745a (diff) |
select_from, max_len
-rwxr-xr-x | max_len | 16 | ||||
-rwxr-xr-x | select_from | 19 |
2 files changed, 35 insertions, 0 deletions
@@ -0,0 +1,16 @@ +#!/usr/bin/env ruby + +require 'zipf' + +max = ARGV[0].to_i + +i = 0 +while line = STDIN.gets + if tokenize(line).size <= max + puts i + else + STDERR.write line + end + i += 1 +end + diff --git a/select_from b/select_from new file mode 100755 index 0000000..14fbc9e --- /dev/null +++ b/select_from @@ -0,0 +1,19 @@ +#!/usr/bin/env ruby + +require 'zipf' + +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] + STDOUT.write line + end + i += 1 +end + |