#!/usr/bin/env ruby require 'trollop' STDIN.set_encoding 'utf-8' STDOUT.set_encoding 'utf-8' def usage STDERR.write "splitpipes -f < \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