bash
maintains a history of commands that have been entered. This list of commands is kept in your home directory in a file called .bash_history. The history facility is a useful resource for reducing the amount of typing you have to do, especially when combined with command-line editing.. Let’s say we want to find the commands we used to list /usr/bin. Here is one way we could do this: lists some of the keystrokes used to manipulate the history list.I would caution against using the !string
and !?string
forms unless you are absolutely sure of the contents of the history list items.
Many more elements are available in the history expansion mechanism, but this subject is already too arcane and our heads may explode if we continue. The section of the bash
man page goes into all the gory details. Feel free to explore!
In this chapter we have covered some of the keyboard tricks that the shell provides to help hardcore typists reduce their workloads. I suspect that as time goes by and you become more involved with the command line, you will refer to this chapter to pick up more of these tricks. For now, consider them optional and potentially helpful.