Reputation: 32276
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
The above works as expected and shows the results for today's date. But the following does not work.
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
I tried to escape the space and that did not work as well.
tail /mnt/mysqld_log/mysql_error_log.err | grep -e `date +'%y%m%d\ %k' --date='4 hour ago'` | more
grep: Trailing backslash
Upvotes: 0
Views: 3057
Reputation: 4879
You need to wrap the date
command with quotes:
tail /mnt/mysqld_log/mysql_error_log.err | grep -e "`date +'%y%m%d %k' --date='4 hour ago'`" | more
The space is being interpreted as the file you are trying to read from, by encasing it in quotes, this will not happen.
Upvotes: 2