我想grep
行以#
或#*
或number
或#number
开头。换句话说,我希望从cron命令开始到结束为止。我不需要crontab头。 这里是crontab文件:cron模式匹配
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
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)
#*/56 * * * * root bash /media/data/minutely.sh
#20 * * * * root bash /media/data/hourly.sh
#* * * * * root bash /media/data/looping.sh
* * * * * root bash /media/data/looping2.sh
20 * * * * root bash /media/data/hourly2.sh
而我想要的是:
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)
#*/56 * * * * root bash /media/data/minutely.sh
#20 * * * * root bash /media/data/hourly.sh
#* * * * * root bash /media/data/looping.sh
* * * * * root bash /media/data/looping2.sh
20 * * * * root bash /media/data/hourly2.sh
.
.
.
.
#until end of line
我已经尝试:
cat /etc/crontab | grep '^[^#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)
如何才能grep只能拍我已经在上面解释过了吗? 对不起,英语不好。
使用,而不是'^ [#0-9]' – hjpotter92 2014-10-11 13:41:22
对不起,先生,我有尝试,但输出仍给我的标题(从'#/ etc/crontab'直到'#没有其他crontabs做.') – 2014-10-11 13:43:16