From: Tobi Reif Date: 2006-03-14T01:46:50+09:00 Subject: simple one-liners: last line missing Hi Let's say I'd want to modify each line of a file. Here's the dummy data: $ cat data.txt first foo second foo third foo $ This works: $ ruby -ne '$_ =~ /(\S+)\s+(\S+)/;puts "#{$2} #{$1}"' data.txt foo first foo second foo third $ I don't really need to achieve that modification. Instead I'd like to understand why the following version one doesn't work: $ ruby -pe 'sub(/(\S+)\s+(\S+)/,"#{$2} #{$1}")' data.txt foo first foo second $ TIA, Tobi