Maintaining your bash command line history in Linux
Introduction Every system administrator is a frequent user of the bash history command to recall previously executed actions. We frequently use the bash shells’ history feature to check what commands we executed previously on the system and also re-execute some of the commands if required. This often results in a lot of time being saved as we don’t have to retype lengthy commands on the terminal. We can just recall them from the shell history if we had used them earlier. We’ve already shared two posts earlier on the bash shell history namely bash history capabilities and replace occurrences of words in last command in bash history . In this article, we’ll show you how can use a few shell environment variables to make your bash shell history become very efficient. Before we get to discussing the environment variables, we would like to mention how you could view only particular count of commands from the entire command line history. You could pipe the output of the history command to the head and/or tail commands if you are interested in only a subset of the complete output. Or you can use the history command followed by the number of commands you’d like to see. Note that this number will be in descending order from the most recently executed command. For example, to view the last 50 commands in history, type: history 50 The...
Read More