Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Print the history for the last 10 Commands on the session on each log in to the shell

so I’m trying to print out the last 10 commands on the last session on each login, in the
bash.bashrc i wrote this:
echo "$(history 10)"
but it didn’t print anything

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Bash history is only loaded from file after .bashrc has completed.

You can force the loading of history and then output what you want by adding the following to your .bashrc file:

history -r
history 10
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading