#!/usr/bin/env ruby require 'trollop' STDIN.set_encoding 'utf-8' STDOUT.set_encoding 'utf-8' cfg = Trollop::options do banner "splitpipes -f < " 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