0

I like to get todays entries from log file so that I can send that to my email every day. This is my command, its not working please help.

cat /var/log/fail2ban.log | grep "date +%Y\-%m\-%d"
Fredrik Pihl
  • 44,604
  • 7
  • 83
  • 130
sathees
  • 11
  • 1
  • 2

1 Answers1

1

I will put my comment as an answer.

You want this:

cat /var/log/fail2ban.log | grep `date +%Y-%m-%d`

The text between the two backticks ` is executed by your shell, and is replaced by the output of the command.

UltraInstinct
  • 43,308
  • 12
  • 81
  • 104
  • 1
    backtics are [deprecated](http://stackoverflow.com/a/4708569/297323) perhaps update your answer with `$(...)` – Fredrik Pihl Apr 26 '13 at 13:39
  • I like to get yesterday entries from log file so that I can send that to my email every day. This command will provide today’s from log file cat /var/log/fail2ban.log | grep `date +%Y\-%m\-%d` how do i rewrite this command for yesterday entries? – sathees Apr 26 '13 at 20:39