-7

Here is my Controlled Assessment:

Show and explain the content of the file that contains the Bash history.

I typed ls -a, but all it did was show files called Bash History which I couldn't open :(

So how do I do it then?

  • 6
    It is probably downvoted because some users feel that it was too basic and that you should ideally study and test various solutions before asking. The best questions are on the form "I want to do this, so I tried this but I get this rather than what I expected, which is this." In your question, you give no clue as to how you tried opening the file, and what happened then. Also, be very specific.; there are probably no files called Bash History, and if there were there would only be one (a directory can not hold multiple things with the same name). – Kusalananda Feb 23 '17 at 10:37
2

To show the history in bash:

$ history

This will show the (in memory) history of the current shell.

$ cat "$HISTFILE"

This will output the history saved to this file by previous bash sessions when they have exited (or written to the file under other circumstances).

See the bash manual and search for variables therein that start with HIST. These affect the format of the output of the history command and the location and size of the history file as well as what is put into it.

You should also consult the same manual for an explanation of the history command and when the history gets written to the history file (search the manual for history -s). Also read the section called HISTORY (search ^HISTORY).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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