16

How can I view the terminal history for a specific date?

For example today is 4-apr and I want to view the history of 31-mar

26

You can set the history format to include the date using the following:

HISTTIMEFORMAT="%d/%m/%y %T "

Then filter for a specific date using grep:

history | grep "31/03"

More info:

  • 4
    Note that HISTTIMEFORMAT should already have been set during this period, or bash will just use today's date. – muru Apr 5 '17 at 2:16
  • @Kamil - thanks for the message about HISTTIMEFORMAT! – Yaron Apr 5 '17 at 12:09
  • @kulwinder1986 - if I've answered your question please accept / up-vote my answer. – Yaron Jul 30 '17 at 12:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.