From: Derek Smith Date: 2009-12-23T13:12:11+09:00 Subject: awk print $4 in ruby Hi All, I had played in Ruby a while and could not get this to work. df -m Filesystem 1M-blocks Used Avail Capacity Mounted on /dev/concat/v109-v112a 7931 2619 4677 36% / [root@vr /usr/local/vrep/OS_scripts]# df -k |awk '{print $4}' Avail 4789776 dfstr = Array.new dfstr << %x(df -m) dfstr.each do |line| puts line if line =~ /(\d+)%/ end Since its one line, it of course prints it all. I then tried: dfstr.each do |line| puts line.split[3] end And it only prints "Avail" I then tried: puts dfstr.scan(/Avail.*/) and puts dfstr.split(/\d+/)[3] with NO success. Goal is to get certain data columns such as Used Avail Capacity. thank you! -- Posted via http://www.ruby-forum.com/.