From: Peter Hickman Date: 2011-11-09T07:09:45+09:00 Subject: Re: Parsing data with ruby Well this is a bit of a hack but just to simply parse the lines you could use: a = "10,25,40,55 * * * * /some/cron/here > /dev/null 2>&1\n30 */4 * * * /some/cron/here" a.split(/\n/).each do |line| if line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/ output = Array.new output << $6 output << "?" output << ($1 == "*" ? 'N' : 'Y') output << ($2 == "*" ? 'N' : 'Y') output << ($3 == "*" ? 'N' : 'Y') output << ($4 == "*" ? 'N' : 'Y') output << ($5 == "*" ? 'N' : 'Y') p output end end Which will output: ["/some/cron/here > /dev/null 2>&1", "?", "Y", "N", "N", "N", "N"] ["/some/cron/here", "?", "Y", "Y", "N", "N", "N"] Note that I left the '?' for the number of servers as that is your problem - Think of it as an exercise for the reader :) Also you might also need to match the Paul Vixie extensions for cron such as @hourly and @daily