From: John Knight Date: 2002-05-29T12:03:52+09:00 Subject: Re: [ma-linux] Seeking the right (most) Hi All, I put the following message on ruby-talk@ruby-lang.org malug is discussing the following question: How to print the rightmost word for every line in ? I tried to introduce ruby to the debate. But am not sure I have the best solution. ruby -ne 'arr=split; puts "#{arr.last}"' #john I less than three hours, I got the following replies: ruby -ne "arr=split; puts arr.last" [file] #Tobi ruby -nae 'puts $F[-1]' You'll get nils in the output for blank lines; depending on what you want to ruby -nae 'puts $F[-1] if $F[-1]' ruby -lane 'puts $F[-1] || ""' # Dossy Much though I like Ruby, I use "awk '{print $NF'}" for that. Clifford Heath ruby -lane 'print $F[-1]' # matz < matz is the creator of ruby.> ruby -ne 'puts split.last' ruby -nae 'puts $F.last' #But it prints 'nil' for empty lines.Mike Hall All this -- including a response from matz. We are in a real learning community. :) My favorite is object oriented. But probably includes an unnecessary split. ruby -ne 'puts split.last' John