From: Derek Smith Date: 2009-12-24T02:06:48+09:00 Subject: Re: awk print $4 in ruby Derek Smith wrote: >>> df -k | ruby -lane 'print $F[3]' >> >> yes and no. I prefer it in script form no CLI form. >> >> dfstr = Array.new >> dfstr << %x(df -m) >> dfstr.each do |line| >> ????? >> end > > Tried this too: > > $; = 'Avail' > dfstr = %x(df -m) > puts dfstr[$;] I got it using, but ideally would not like to use a file on the FS. Any comments welcome! :) Merry Xmas! Thank you! DFSTR = "/tmp/dfstr.out" %x(df -m > "#{DFSTR}") file = File.open("#{DFSTR}", "r") file.each do |ln| ln.chomp fsaray = [] fsaray = ln.split puts fsaray[3] end -- Posted via http://www.ruby-forum.com/.