Tip For Tech Bloggers: Easy Way to Document Command History

While writing technical blogs, it’s always nice to include commands and scripts that readers can try on their own. I find it a bit challenging to accurately document these in steps while intensively testing or debugging something by myself.

There are actually commands that faithfully list all the commands you typed. You can then clean them up for your posts. In the following, I introduce how to do these on Linux, Windows.

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

Linux

If you familiar with Linux, you can simply type in the following command:

$ history

You will see all the commands you ran before on the console. You can also save them into a file with Linux pipeline. With the saved file, you can download it and edit it.

$ history > history.txt

Note that the history is per user base. If you switch user and type more commands there, these commands would not be included in the current shell command after you return. You can either save them before you exiting the other shell or returning back again.

For more information on the history command, you can type in “-h” like other command for help.

Here is a nice article with deeper discussion on the history command combined with other settings, for example, find out what time the commands were executed.

Windows

On windows, you can use the doskey command like the following:

> doskey /history > history.txt

If you want to append the historical commands to an existing file, you can do this:

> doskey /history >> \history.txt

If you need help, you can type in

> doskey /?

Note that the history is per session and not persistent, meaning you will lose the history after you close the DOS window. Make sure you constantly run the doskey command to minimize the risk of accidental closing.

Here is a page with more details from Microsoft.

Mac

I know there should be a section for Mac, but I don’t use Mac these days. If you know how to do it, please feel free to leave a comment. Thanks!

This entry was posted in Software Development and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Posted June 10, 2013 at 12:41 am | Permalink

    Tip For Tech Bloggers: Easy Way to Document Command History (DoubleCloud) http://t.co/RvIycgP3sY

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  • NEED HELP?


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.