Peter Vandenabeele wrote in post #968289: > On Tue, Dec 14, 2010 at 2:32 PM, Rajesh M. <munikur / gmail.com> wrote: >> 0 10 * * 0 sync; sync; reboot <---- regex should look for only sync; >> For example in another system if the crontab entry is like: >> 0 6 * * 0 shutdown -y -g0 -i6 >> regular expression should only look for the string after digitals 0 6 * >> * 0, here it should look for shutdown -y -g0 -i6 > > If on the commandline, 'cut' may be useful. > > $ cat crontab | egrep '^[0-9\*]' > 17 * * * * root cd / && run-parts --report /etc/cron.hourly > 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts > --report /etc/cron.daily ) > 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts > --report /etc/cron.weekly ) > 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts > --report /etc/cron.monthly ) > > $ cat crontab | egrep '^[0-9\*]' | cut -f3- > root cd / && run-parts --report /etc/cron.hourly > root test -x /usr/sbin/anacron || ( cd / && run-parts --report > /etc/cron.daily ) > root test -x /usr/sbin/anacron || ( cd / && run-parts --report > /etc/cron.weekly ) > root test -x /usr/sbin/anacron || ( cd / && run-parts --report > /etc/cron.monthly ) > > 'cut' splits by default on <TAB> and there seem to be exactly 2 TAB's > before the 'root' > part (you can use $ od -ax crontab to check that in detail). > > HTH, > > Peter cat /tmp/cron.list | egrep '^[0-9\*]' 00 01 * * 0 (sync ; sync ; sync ; /sbin/reboot) 00 18 * * 6 (sync; sync; sync; /sbin/reboot) Not sure it is still getting digits, what am doing wrong here? -- Posted via http://www.ruby-forum.com/.