Charly's Column – Shell History

Charly's Column – Shell History

Article from Issue 243/2021
Author(s):

For admins like Charly, who try to avoid typing at all costs, the shell offers an excellent opportunity to avoid wear on your fingertips in the form of built-in history.

There are commands that I type several dozen times a day – grep <something> /var/log/syslog is such a classic. The shell keeps a history of all my entries; thanks to the history command, I can always see in a numbered list which commands I typed last.

The history command is not a separate tool; typing which history at the command line just drops you into a black hole. Instead, history is a part of the shell, a built-in keyword. history's killer feature, for which lazy people like me are eternally grateful, is the interactive search. You enable it with Ctrl+R, changing the command-line prompt to (reverse-i-search)`':.

If you start typing now, for example, the word net, the shell will show you the last command typed containing net. When you press Ctrl+R again, the history feature shows you an increasing number of older commands that contain net (Figure 1).

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Effectively using Bash history

    You can do more with the Bash history command than just using the arrow keys. We show you how to use this command-line tool more efficiently.

  • Bash History on Steroids

    You can always browse the Bash history using your arrow keys, but Bash's search capabilities are very limited. Enter the clever Bash History Suggest Box.

  • McFly

    When it comes to working at the command line, using Bash history effectively can save you time. McFly extends the Bash history's features and helps you find past commands more quickly.

  • Command Line

    A few basic tricks can liven up the command line and add a dash of color to your console.

  • Making History

    In the history log, the Bash shell records all commands typed by the user. Mike Schilli extracts this data with Go for a statistical analysis of his typing behavior.

comments powered by Disqus