From: Ryan Davis Date: 2010-12-15T08:21:20+09:00 Subject: Re: Grep a string On Dec 14, 2010, at 07:21 , Rob Biedenharn wrote: > Well, you asked on a Ruby list so you're getting a Ruby answer from me. > > crontab -l | ruby -nle 'next if $_ =~ /^\s*#/; fields = $_.split(" ",6); puts fields.inspect;' Don't forget the -a flag! % ruby -h | grep -- -a -a autosplit mode with -n or -p (splits $_ into $F) -Fpattern split() pattern for autosplit (-a) so you can do something like: % ruby -nae 'next unless $_ =~ /^[\d\*]/; p $F' crontab.envy.zenspider.com ["*/5", "*", "*", "*", "*", "~/Work/p4/zss/src/scripts/dev/p4autotest.sh"] ["*/5", "*", "*", "*", "*", "~/Work/p4/zss/src/scripts/dev/p4review.py"] ["*/15", "*", "*", "*", "*", "/Volumes/Users/www/zenspider.com/bin/webupdate.sh"] ["0", "*", "*", "*", "*", "(imap_cleanse", "&&", "imap_flag)", "&>", "/dev/null"] ["12", "*", "*", "*", "*", "cd", "~/Work/git/synchronizer", "&&", "rake", "-s", "sync"]