#!/usr/bin/env ruby # coding: euc-jp # ./cat-n.rb 5000 とすれば5000回。省略時1000回。 repeat = (ARGV[0] || 1000).to_i IO.popen("cat -n", "r+") do |c| 0.upto(repeat) {|i| c.puts i} c.close_write while line=c.gets print line end end