summaryrefslogtreecommitdiff
path: root/split_pipes
diff options
context:
space:
mode:
Diffstat (limited to 'split_pipes')
-rwxr-xr-xsplit_pipes23
1 files changed, 23 insertions, 0 deletions
diff --git a/split_pipes b/split_pipes
new file mode 100755
index 0000000..eeba69b
--- /dev/null
+++ b/split_pipes
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+
+require 'trollop'
+
+STDIN.set_encoding 'utf-8'
+STDOUT.set_encoding 'utf-8'
+
+cfg = Trollop::options do
+ banner "splitpipes -f <n> < <input>"
+ opt :field, "field", :type => :int
+end
+
+while line = STDIN.gets
+ j = 1
+ line.strip.split(' ||| ').each { |i|
+ if j == cfg[:field]
+ puts i.strip
+ break
+ end
+ j += 1
+ }
+end
+