diff options
author | Patrick Simianer <p@simianer.de> | 2013-12-05 07:56:38 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2013-12-05 07:56:38 +0100 |
commit | db6a6ecfa350cae29739c59df1210d8f76a479c9 (patch) | |
tree | f137a001f57f170455c28ce97b5abb2726006cf6 /splitpipes |
init
Diffstat (limited to 'splitpipes')
-rwxr-xr-x | splitpipes | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/splitpipes b/splitpipes new file mode 100755 index 0000000..b0c3c9c --- /dev/null +++ b/splitpipes @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby + +require 'trollop' + + +STDIN.set_encoding 'utf-8' +STDOUT.set_encoding 'utf-8' + +def usage + STDERR.write "splitpipes -f <n> < <input>\n" + exit 1 +end +usage if ARGV.size!=2 + +opts = Trollop::options do + opt :field, "field", :type => :int +end + +while line = STDIN.gets + j = 1 + line.strip.split(' ||| ').each { |i| + if j == opts[:field] + puts i.strip + break + end + j += 1 + } +end + |