grep中的逃逸空间
以上工作如预期,并显示了今天的结果。但以下方法不起作用grep中的逃逸空间,grep,Grep,以上工作如预期,并显示了今天的结果。但以下方法不起作用 tail /mnt/mysqld_log/mysql_error_log.err | grep -e `date +'%y%m%d' --date='4 hour ago'` | more 120824 11:25:06 [ERROR] /usr/libexec/mysqld: Table '.zone_assoc' is marked as crashed and should be repaired 120824 18:03:23
tail /mnt/mysqld_log/mysql_error_log.err | grep -e `date +'%y%m%d' --date='4 hour ago'` | more
120824 11:25:06 [ERROR] /usr/libexec/mysqld: Table '.zone_assoc' is marked as crashed and should be repaired
120824 18:03:23 [ERROR] /usr/libexec/mysqld: Incorrect key file for table '.ad_zone_assoc.MYI'; try to repair it
120824 18:08:38 [ERROR] /usr/libexec/mysqld: Incorrect key file for table '.ad_zone_assoc.MYI'; try to repair it
我试图逃离这个空间,但没有成功
tail /mnt/mysqld_log/mysql_error_log.err | grep -e `date +'%y%m%d %k' --date='4 hour ago'` | more
grep: 18: No such file or directory
您需要将
date
命令用引号括起来:
tail /mnt/mysqld_log/mysql_error_log.err | grep -e `date +'%y%m%d\ %k' --date='4 hour ago'` | more
grep: Trailing backslash
空间被解释为您试图读取的文件,通过将其括在引号中,这不会发生。确切的cron命令是什么?您可能需要将其放入包装器脚本中才能按预期工作,但请将cron发送给我,我将看看我能做些什么。cron条目在转义%符号后工作。谢谢你的快速帮助。
tail /mnt/mysqld_log/mysql_error_log.err | grep -e "`date +'%y%m%d %k' --date='4 hour ago'`" | more