0
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

我试图逃离这个空间,但效果不佳。

tail /mnt/mysqld_log/mysql_error_log.err  | grep -e `date +'%y%m%d\ %k' --date='4 hour ago'` | more

grep: Trailing backslash
4

1 回答 1

2

您需要date用引号将命令包装起来:

tail /mnt/mysqld_log/mysql_error_log.err  | grep -e "`date +'%y%m%d %k' --date='4 hour ago'`" | more

该空间被解释为您尝试从中读取的文件,通过将其括在引号中,这不会发生。

于 2012-08-24T17:01:05.273 回答