From: Panagiotis Atmatzidis Date: 2009-12-05T05:09:35+09:00 Subject: awk to ruby 1.9 Hello, I'm a total newbe. I'm trying to figure out how to grab a specific Xth character from a .log and put it into an array. So far, I've got to this code snippet: ------------ # encoding: utf-8 class ReadIPs def initialize @read_ips = [] end def get_ips(filename) ips = [] # make a list of ip addressses File.foreach(filename) do |line| puts "#{line}" if line =~ /Ban/ end end end ipadds = ReadIPs.new a = ipadds.get_ips("fail2ban.log") -------------- The output though parses lines the following: 2009-11-19 00:31:29,928 fail2ban.actions: WARNING [ssh-ipfw] Ban 203.169.139.171 Now, I'd like to isolate the IP and put it into an Array. I would like to use the output from the cli: "$ grep Ban fail2ban.log|awk -F "Ban" '{print $2}'" 60.12.200.xx 193.193.221.xx 85.72.xx.xx 124.207.xx.xx regards Panagiotis (atmosx) Atmatzidis email: atma@convalesco.org URL: http://www.convalesco.org GnuPG ID: 0xFC4E8BB4 gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xFC4E8BB4 -- The wise man said: "Never argue with an idiot. They bring you down to their level and beat you with experience."